⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 download_list.cc

📁 rtorrent
💻 CC
📖 第 1 页 / 共 2 页
字号:
  download->variable()->set("state", (int64_t)0);  pause(download);}boolDownloadList::stop_try(Download* download) {  check_contains(download);  if (download->variable()->get_value("ignore_commands") != 0)    return false;  download->variable()->set("state", (int64_t)0);  pause(download);  return true;}voidDownloadList::resume(Download* download) {  check_contains(download);  try {    if (download->download()->is_active())      return;    // Manual or end-of-download rehashing clears the resume data so    // we can just start the hashing again without clearing it again.    //    // It is also assumed the is_hash_checked flag gets cleared when    // 'hashing' was set.    if (!download->is_hash_checked()) {      // If the hash failed flag wasn't cleared then hashing won't be      // initiated.      if (download->is_hash_failed())        return;      if (download->variable()->get_value("hashing") == Download::variable_hashing_stopped)        download->variable()->set("hashing", Download::variable_hashing_initial);      std::for_each(slot_map_hash_queued().begin(), slot_map_hash_queued().end(), download_list_call(download));      return;    }    open_throw(download);    download->variable()->set("state_changed", cachedTime.seconds());    if (download->is_done()) {      download->set_connection_type(download->variable()->get_string("connection_seed"));    } else {      download->set_connection_type(download->variable()->get_string("connection_leech"));      // For the moment, clear the resume data so we force hash-check      // on non-complete downloads after a crash. This shouldn't be      // needed, but for some reason linux 2.6 is very lazy about      // updating mtime.      torrent::resume_save_progress(*download->download(), download->download()->bencode()->get_key("libtorrent_resume"), true);    }    // Update the priority to ensure it has the correct    // seeding/unfinished modifiers.    download->set_priority(download->priority());    download->download()->start();    std::for_each(slot_map_start().begin(), slot_map_start().end(), download_list_call(download));  } catch (torrent::local_error& e) {    control->core()->push_log(e.what());  }}voidDownloadList::pause(Download* download) {  check_contains(download);  try {    // Always clear hashing on pause. When a hashing request is added,    // it should have cleared the hash resume data.    if (download->variable()->get_value("hashing") != Download::variable_hashing_stopped) {      download->download()->hash_stop();      download->variable()->set_value("hashing", Download::variable_hashing_stopped);      std::for_each(slot_map_hash_removed().begin(), slot_map_hash_removed().end(), download_list_call(download));    }    if (!download->download()->is_active())      return;    download->download()->stop();    torrent::resume_save_progress(*download->download(), download->download()->bencode()->get_key("libtorrent_resume"));        std::for_each(slot_map_stop().begin(), slot_map_stop().end(), download_list_call(download));    download->variable()->set("state_changed", cachedTime.seconds());    // Save the state after all the slots, etc have been called so we    // include the modifications they may make.    //control->core()->download_store()->save(download);  } catch (torrent::local_error& e) {    control->core()->push_log(e.what());  }}voidDownloadList::check_hash(Download* download) {  check_contains(download);  try {    if (download->variable()->get_value("hashing") != Download::variable_hashing_stopped)      return;    hash_queue(download, Download::variable_hashing_rehash);  } catch (torrent::local_error& e) {    control->core()->push_log(e.what());  }}voidDownloadList::hash_done(Download* download) {  check_contains(download);  if (!download->is_open())    throw torrent::client_error("DownloadList::hash_done(...) !download->is_open().");  if (download->is_hash_checking() || download->is_active())    throw torrent::client_error("DownloadList::hash_done(...) download in invalid state.");  if (!download->is_hash_checked()) {    download->set_hash_failed(true);        std::for_each(slot_map_hash_done().begin(), slot_map_hash_done().end(), download_list_call(download));    return;  }  // Need to find some sane conditional here. Can we check the total  // downloaded to ensure something was transferred, thus we didn't  // just hash an already completed torrent with lacking session data?  //  // Perhaps we should use a seperate variable or state, and check  // that. Thus we can bork the download if the hash check doesn't  // confirm all the data, avoiding large BW usage on f.ex. the  // ReiserFS bug with >4GB files.  int64_t hashing = download->variable()->get_value("hashing");  download->variable()->set_value("hashing", Download::variable_hashing_stopped);  switch (hashing) {  case Download::variable_hashing_initial:  case Download::variable_hashing_rehash:    // Normal re/hashing.    // If the download was previously completed but the files were    // f.ex deleted, then we clear the state and complete.    if (download->variable()->get_value("complete") && !download->is_done()) {      download->variable()->set("state", (int64_t)0);      download->set_message("Download registered as completed, but hash check returned unfinished chunks.");    }    // Save resume data so we update time-stamps and priorities if    // they were invalid/changed while loading/hashing.    download->variable()->set("complete", (int64_t)download->is_done());    torrent::resume_save_progress(*download->download(), download->download()->bencode()->get_key("libtorrent_resume"));    if (download->variable()->get_value("state") == 1)      resume(download);    break;  case Download::variable_hashing_last:    if (download->is_done()) {      confirm_finished(download);    } else {      download->set_message("Hash check on download completion found bad chunks, consider using \"safe_sync\".");      control->core()->push_log("Hash check on download completion found bad chunks, consider using \"safe_sync\".");    }        break;  case Download::variable_hashing_stopped:  default:    // Either an error or someone wrote to the hashing variable...    download->set_message("Hash check completed but the \"hashing\" variable is in an invalid state.");    return;  }  std::for_each(slot_map_hash_done().begin(), slot_map_hash_done().end(), download_list_call(download));}voidDownloadList::hash_queue(Download* download, int type) {  check_contains(download);  if (download->variable()->get_value("hashing") != Download::variable_hashing_stopped)    throw torrent::client_error("DownloadList::hash_queue(...) hashing already queued.");  close_throw(download);  torrent::resume_clear_progress(*download->download(), download->download()->bencode()->get_key("libtorrent_resume"));  download->set_hash_failed(false);  download->variable()->set_value("hashing", type);  if (download->is_open())    throw torrent::internal_error("DownloadList::hash_clear(...) download still open.");  // If any more stuff is added here, make sure resume etc are still  // correct.  std::for_each(slot_map_hash_queued().begin(), slot_map_hash_queued().end(), download_list_call(download));}voidDownloadList::received_finished(Download* download) {  check_contains(download);  if (control->variable()->get_value("check_hash")) {    // Set some 'checking_finished_thingie' variable to make hash_done    // trigger correctly, also so it can bork on missing data.    hash_queue(download, Download::variable_hashing_last);  } else {    confirm_finished(download);  }}// The download must be open when we call this function.voidDownloadList::confirm_finished(Download* download) {  check_contains(download);  download->variable()->set("complete", (int64_t)1);  download->set_connection_type(download->variable()->get_string("connection_seed"));  download->set_priority(download->priority());  if (download->variable_value("min_peers") == control->variable()->get_value("min_peers") && control->variable()->get_value("min_peers_seed") >= 0)    download->variable()->set("min_peers", control->variable()->get("min_peers_seed"));  if (download->variable_value("max_peers") == control->variable()->get_value("max_peers") && control->variable()->get_value("max_peers_seed") >= 0)    download->variable()->set("max_peers", control->variable()->get("max_peers_seed"));  // Do this before the slots are called in case one of them closes  // the download.  if (!download->is_active() && control->variable()->get_value("session_on_completion") != 0) {    torrent::resume_save_progress(*download->download(), download->download()->bencode()->get_key("libtorrent_resume"));    control->core()->download_store()->save(download);  }  // Send the completed request before resuming so we don't reset the  // up/downloaded baseline.  download->download()->tracker_list().send_completed();  std::for_each(slot_map_finished().begin(), slot_map_finished().end(), download_list_call(download));  if (!download->is_active() && download->variable()->get_value("state") == 1)    resume(download);}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -