From f6d71f8b9db6d84fd1fc76c6a37462bb202fb5e2 Mon Sep 17 00:00:00 2001 From: levlam Date: Tue, 1 Mar 2022 16:01:40 +0300 Subject: [PATCH] DownloadManager: add files with correct size and downloaded_size. --- td/telegram/DownloadManager.cpp | 5 +++++ td/telegram/Td.cpp | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/td/telegram/DownloadManager.cpp b/td/telegram/DownloadManager.cpp index 491a67574..be3c6c785 100644 --- a/td/telegram/DownloadManager.cpp +++ b/td/telegram/DownloadManager.cpp @@ -377,6 +377,11 @@ class DownloadManagerImpl final : public DownloadManager { CHECK(file_info != nullptr); auto download_id = file_info->download_id; file_info->internal_file_id = callback_->dup_file_id(file_info->file_id); + auto file_view = callback_->get_file_view(file_info->file_id); + CHECK(!file_view.empty()); + file_info->size = file_view.expected_size(); + file_info->downloaded_size = file_view.local_total_size(); + by_internal_file_id_[file_info->internal_file_id] = download_id; by_file_id_[file_info->file_id] = download_id; hints_.add(download_id, search_text.empty() ? string(" ") : search_text); diff --git a/td/telegram/Td.cpp b/td/telegram/Td.cpp index 3da604ab4..7610e99cd 100644 --- a/td/telegram/Td.cpp +++ b/td/telegram/Td.cpp @@ -4027,7 +4027,7 @@ void Td::init_managers() { auto td = G()->td().get_actor_unsafe(); auto file_view = td->file_manager_->get_file_view(file_id); send_closure(download_manager_, &DownloadManager::update_file_download_state, file_id, - file_view.local_total_size(), file_view.size(), !file_view.is_downloading()); + file_view.local_total_size(), file_view.expected_size(), !file_view.is_downloading()); // TODO: handle deleted state? } void on_download_ok(FileId file_id) final {