diff --git a/src/core/download.h b/src/core/download.h index 6c0965a8..e654e285 100644 --- a/src/core/download.h +++ b/src/core/download.h @@ -22,6 +22,8 @@ public: typedef torrent::ConnectionList connection_list_type; typedef download_type::ConnectionType connection_type; + static constexpr uint32_t default_resume_flags = ~uint32_t{} & ~torrent::Download::open_enable_fallocate; + static const int variable_hashing_stopped = 0; static const int variable_hashing_initial = 1; static const int variable_hashing_last = 2; @@ -100,7 +102,7 @@ private: download_type m_download; bool m_hashFailed{}; std::string m_message; - uint32_t m_resumeFlags{~uint32_t{}}; + uint32_t m_resumeFlags{default_resume_flags}; unsigned int m_group{}; }; diff --git a/src/core/download_list.cc b/src/core/download_list.cc index d208fdf6..79854c6a 100644 --- a/src/core/download_list.cc +++ b/src/core/download_list.cc @@ -331,7 +331,7 @@ DownloadList::resume(Download* download, int flags) { // 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()) + if (download->resume_flags() == Download::default_resume_flags) download->set_resume_flags(flags); // Manual or end-of-download rehashing clears the resume data so @@ -404,7 +404,7 @@ DownloadList::resume(Download* download, int flags) { download->set_priority(download->priority()); download->download()->start(download->resume_flags()); - download->set_resume_flags(~uint32_t()); + download->set_resume_flags(Download::default_resume_flags); DL_TRIGGER_EVENT(download, "event.download.resumed"); @@ -421,7 +421,7 @@ DownloadList::pause(Download* download, int flags) { try { - download->set_resume_flags(~uint32_t()); + download->set_resume_flags(Download::default_resume_flags); rpc::parse_command_single(rpc::make_target(download), "view.set_not_visible=active"); @@ -660,8 +660,8 @@ DownloadList::confirm_finished(Download* download) { if (find(infohash) == end()) return; -// if (download->resume_flags() != ~uint32_t()) -// throw torrent::internal_error("DownloadList::confirm_finished(...) download->resume_flags() != ~uint32_t()."); +// if (download->resume_flags() != Download::default_resume_flags) +// throw torrent::internal_error("DownloadList::confirm_finished(...) download->resume_flags() != Download::default_resume_flags."); // See #1292. // @@ -671,7 +671,7 @@ DownloadList::confirm_finished(Download* download) { // // TODO: Add a check when setting the flags to see if the torrent is // being hashed. - download->set_resume_flags(~uint32_t()); + download->set_resume_flags(Download::default_resume_flags); if (!download->is_active() && rpc::call_command_value("d.state", rpc::make_target(download)) == 1) resume(download,