Skip to content

Commit

Permalink
Only write uncertain_pieces.timestamp when necessary
Browse files Browse the repository at this point in the history
  • Loading branch information
kannibalox authored and rakshasa committed Nov 13, 2024
1 parent f4a99eb commit 3978ee3
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/torrent/utils/resume.cc
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ resume_save_uncertain_pieces(Download download, Object& object) {
// Add information on what chunks might still not have been properly
// written to disk.
object.erase_key("uncertain_pieces");
object.insert_key("uncertain_pieces.timestamp", rak::timer::current_seconds());
object.erase_key("uncertain_pieces.timestamp");

const TransferList::completed_list_type& completedList = download.transfer_list()->completed_list();
TransferList::completed_list_type::const_iterator itr =
Expand All @@ -384,6 +384,7 @@ resume_save_uncertain_pieces(Download download, Object& object) {
for (std::vector<uint32_t>::iterator itr2 = buffer.begin(), last = buffer.end(); itr2 != last; itr2++)
*itr2 = htonl(*itr2);

object.insert_key("uncertain_pieces.timestamp", rak::timer::current_seconds());
Object::string_type& completed = object.insert_key("uncertain_pieces", std::string()).as_string();
completed.append((const char*)&buffer.front(), buffer.size() * sizeof(uint32_t));
}
Expand Down

0 comments on commit 3978ee3

Please sign in to comment.