From 0038868a0bf935abbb164466e56afd3ecfaa4333 Mon Sep 17 00:00:00 2001 From: Ivan Date: Sun, 18 Oct 2026 07:42:14 +0300 Subject: [PATCH] Clear a stale hash check message after a complete hash check --- src/core/download_list.cc | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/src/core/download_list.cc b/src/core/download_list.cc index 8d95105f..1860f46c 100644 --- a/src/core/download_list.cc +++ b/src/core/download_list.cc @@ -586,6 +586,23 @@ DownloadList::hash_done(Download* download) { if (download->is_done() && download->download()->info()->is_meta_download()) return process_meta_download(download); + constexpr auto completed_unfinished_message = + "Download registered as completed, but hash check returned unfinished chunks."; + constexpr auto final_bad_chunks_message = "Hash check on download completion found bad chunks."; + constexpr auto invalid_hashing_message = + "Hash check completed but the \"hashing\" variable is in an invalid state."; + + // A pass that found every chunk retires the diagnoses an earlier pass set + // below. Any other message is left alone. + if (download->is_done() && + (hashing == Download::variable_hashing_initial || + hashing == Download::variable_hashing_rehash || + hashing == Download::variable_hashing_last) && + (download->message() == completed_unfinished_message || + download->message() == final_bad_chunks_message || + download->message() == invalid_hashing_message)) + download->set_message(""); + switch (hashing) { case Download::variable_hashing_initial: case Download::variable_hashing_rehash: @@ -595,7 +612,7 @@ DownloadList::hash_done(Download* download) { // f.ex deleted, then we clear the state and complete. if (rpc::call_command_value("d.complete", rpc::make_target(download)) && !download->is_done()) { set_state_stopped(download); - download->set_message("Download registered as completed, but hash check returned unfinished chunks."); + download->set_message(completed_unfinished_message); } // Save resume data so we update time-stamps and priorities if @@ -619,7 +636,7 @@ DownloadList::hash_done(Download* download) { if (download->is_done()) { confirm_finished(download); } else { - download->set_message("Hash check on download completion found bad chunks."); + download->set_message(final_bad_chunks_message); LT_LOG_DOWNLOAD_EVENTS("hash check on download completion found bad chunks", 0); DL_TRIGGER_EVENT(download, "event.download.hash_final_failed"); @@ -631,7 +648,7 @@ DownloadList::hash_done(Download* download) { 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."); + download->set_message(invalid_hashing_message); return; }