mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-08-14 06:02:31 +00:00
* Added torrent::Download::{start2,stop2}(int flags) that will replace
the old start/stop functions. The old functions are now just wrappers for the new. * Fixed the tracker requests when finishing a torrent. git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@965 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
@@ -61,7 +61,8 @@ Download::Download(download_type d) :
|
||||
|
||||
m_hashFailed(false),
|
||||
|
||||
m_chunksFailed(0) {
|
||||
m_chunksFailed(0),
|
||||
m_resumeFlags(~uint32_t()) {
|
||||
|
||||
m_connTrackerSucceded = m_download.signal_tracker_succeded(sigc::bind(sigc::mem_fun(*this, &Download::receive_tracker_msg), ""));
|
||||
m_connTrackerFailed = m_download.signal_tracker_failed(sigc::mem_fun(*this, &Download::receive_tracker_msg));
|
||||
|
||||
@@ -100,6 +100,9 @@ public:
|
||||
uint32_t priority();
|
||||
void set_priority(uint32_t p);
|
||||
|
||||
uint32_t resume_flags() { return m_resumeFlags; }
|
||||
void set_resume_flags(uint32_t flags) { m_resumeFlags = flags; }
|
||||
|
||||
void set_root_directory(const std::string& path);
|
||||
|
||||
bool operator == (const std::string& str) const;
|
||||
@@ -124,6 +127,8 @@ private:
|
||||
std::string m_message;
|
||||
uint32_t m_chunksFailed;
|
||||
|
||||
uint32_t m_resumeFlags;
|
||||
|
||||
sigc::connection m_connTrackerSucceded;
|
||||
sigc::connection m_connTrackerFailed;
|
||||
sigc::connection m_connStorageError;
|
||||
|
||||
@@ -329,7 +329,7 @@ DownloadList::stop_try(Download* download) {
|
||||
}
|
||||
|
||||
void
|
||||
DownloadList::resume(Download* download) {
|
||||
DownloadList::resume(Download* download, int flags) {
|
||||
check_contains(download);
|
||||
|
||||
try {
|
||||
@@ -337,6 +337,11 @@ DownloadList::resume(Download* download) {
|
||||
if (download->download()->is_active())
|
||||
return;
|
||||
|
||||
// We need to make sure the flags aren't reset if someone decideds
|
||||
// to call resume() while it is hashing, etc.
|
||||
if (download->resume_flags() == ~uint32_t())
|
||||
download->set_resume_flags(flags);
|
||||
|
||||
// Manual or end-of-download rehashing clears the resume data so
|
||||
// we can just start the hashing again without clearing it again.
|
||||
//
|
||||
@@ -375,7 +380,9 @@ DownloadList::resume(Download* download) {
|
||||
// Update the priority to ensure it has the correct
|
||||
// seeding/unfinished modifiers.
|
||||
download->set_priority(download->priority());
|
||||
download->download()->start();
|
||||
download->download()->start2(download->resume_flags());
|
||||
|
||||
download->set_resume_flags(~uint32_t());
|
||||
|
||||
std::for_each(slot_map_start().begin(), slot_map_start().end(), download_list_call(download));
|
||||
|
||||
@@ -385,11 +392,13 @@ DownloadList::resume(Download* download) {
|
||||
}
|
||||
|
||||
void
|
||||
DownloadList::pause(Download* download) {
|
||||
DownloadList::pause(Download* download, int flags) {
|
||||
check_contains(download);
|
||||
|
||||
try {
|
||||
|
||||
download->set_resume_flags(~uint32_t());
|
||||
|
||||
// Always clear hashing on pause. When a hashing request is added,
|
||||
// it should have cleared the hash resume data.
|
||||
if (rpc::call_command_d_value("d.get_hashing", download) != Download::variable_hashing_stopped) {
|
||||
@@ -402,7 +411,7 @@ DownloadList::pause(Download* download) {
|
||||
if (!download->download()->is_active())
|
||||
return;
|
||||
|
||||
download->download()->stop();
|
||||
download->download()->stop2(flags);
|
||||
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));
|
||||
@@ -510,7 +519,15 @@ DownloadList::hash_queue(Download* download, int type) {
|
||||
if (rpc::call_command_d_value("d.get_hashing", download) != Download::variable_hashing_stopped)
|
||||
throw torrent::internal_error("DownloadList::hash_queue(...) hashing already queued.");
|
||||
|
||||
close_throw(download);
|
||||
// close_throw(download);
|
||||
// HACK
|
||||
if (download->is_open()) {
|
||||
pause(download, torrent::Download::stop_skip_tracker);
|
||||
download->download()->close();
|
||||
std::for_each(slot_map_hash_removed().begin(), slot_map_hash_removed().end(), download_list_call(download));
|
||||
std::for_each(slot_map_close().begin(), slot_map_close().end(), download_list_call(download));
|
||||
}
|
||||
|
||||
torrent::resume_clear_progress(*download->download(), download->download()->bencode()->get_key("libtorrent_resume"));
|
||||
|
||||
download->set_hash_failed(false);
|
||||
@@ -567,11 +584,23 @@ DownloadList::confirm_finished(Download* download) {
|
||||
|
||||
// Close before calling on_finished to ensure the user can do stuff
|
||||
// like change move the downloaded files and change the directory.
|
||||
close_throw(download);
|
||||
// close_throw(download);
|
||||
// HACK:
|
||||
if (download->is_open()) {
|
||||
pause(download, torrent::Download::stop_skip_tracker);
|
||||
download->download()->close();
|
||||
std::for_each(slot_map_hash_removed().begin(), slot_map_hash_removed().end(), download_list_call(download));
|
||||
std::for_each(slot_map_close().begin(), slot_map_close().end(), download_list_call(download));
|
||||
}
|
||||
// END
|
||||
|
||||
std::for_each(slot_map_finished().begin(), slot_map_finished().end(), download_list_call(download));
|
||||
|
||||
if (download->resume_flags() != ~uint32_t())
|
||||
throw torrent::internal_error("DownloadList::confirm_finished(...) download->resume_flags() != ~uint32_t().");
|
||||
|
||||
if (!download->is_active() && rpc::call_command_d_value("d.get_state", download) == 1)
|
||||
resume(download);
|
||||
resume(download, torrent::Download::start_skip_tracker | torrent::Download::start_keep_baseline);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -110,8 +110,10 @@ public:
|
||||
void stop_normal(Download* d);
|
||||
bool stop_try(Download* d);
|
||||
|
||||
void resume(Download* d);
|
||||
void pause(Download* d);
|
||||
void resume(Download* d, int flags = 0);
|
||||
void pause(Download* d, int flags = 0);
|
||||
|
||||
void pause_default(Download* d) { pause(d); }
|
||||
|
||||
void check_hash(Download* d);
|
||||
|
||||
|
||||
+1
-1
@@ -251,7 +251,7 @@ Manager::cleanup() {
|
||||
void
|
||||
Manager::shutdown(bool force) {
|
||||
if (!force)
|
||||
std::for_each(m_downloadList->begin(), m_downloadList->end(), std::bind1st(std::mem_fun(&DownloadList::pause), m_downloadList));
|
||||
std::for_each(m_downloadList->begin(), m_downloadList->end(), std::bind1st(std::mem_fun(&DownloadList::pause_default), m_downloadList));
|
||||
else
|
||||
std::for_each(m_downloadList->begin(), m_downloadList->end(), std::bind1st(std::mem_fun(&DownloadList::close_quick), m_downloadList));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user