diff --git a/src/command_throttle.cc b/src/command_throttle.cc index 664a3aa5..cb9c44b1 100644 --- a/src/command_throttle.cc +++ b/src/command_throttle.cc @@ -36,6 +36,7 @@ #include "config.h" +#include #include #include #include diff --git a/src/core/download_factory.cc b/src/core/download_factory.cc index c0ef0344..f4ed0693 100644 --- a/src/core/download_factory.cc +++ b/src/core/download_factory.cc @@ -388,9 +388,8 @@ DownloadFactory::initialize_rtorrent(Download* download, torrent::Object* rtorre if (rtorrent->has_key_value("total_uploaded")) download->info()->mutable_up_rate()->set_total(rtorrent->get_key_value("total_uploaded")); - if (rtorrent->has_key_value("chunks_done")) - download->download()->set_chunks_done(std::min(rtorrent->get_key_value("chunks_done"), - download->download()->file_list()->size_chunks())); + if (rtorrent->has_key_value("chunks_done") && rtorrent->has_key_value("chunks_wanted")) + download->download()->set_chunks_done(rtorrent->get_key_value("chunks_done"), rtorrent->get_key_value("chunks_wanted")); download->set_throttle_name(rtorrent->has_key_string("throttle_name") ? rtorrent->get_key_string("throttle_name") diff --git a/src/core/download_store.cc b/src/core/download_store.cc index bf13f451..1ce67e87 100644 --- a/src/core/download_store.cc +++ b/src/core/download_store.cc @@ -137,7 +137,8 @@ DownloadStore::save(Download* d, int flags) { torrent::Object* rtorrent_base = &d->download()->bencode()->get_key("rtorrent"); // Move this somewhere else? - rtorrent_base->insert_key("chunks_done", d->download()->file_list()->completed_chunks()); + rtorrent_base->insert_key("chunks_done", d->download()->file_list()->completed_chunks()); + rtorrent_base->insert_key("chunks_wanted", d->download()->data()->wanted_chunks()); rtorrent_base->insert_key("total_uploaded", d->info()->up_rate()->total()); // Don't save for completed torrents when we've cleared the uncertain_pieces.