From b9bf652ad2c41857852058171e234168707bb96a Mon Sep 17 00:00:00 2001 From: levlam Date: Thu, 27 Dec 2018 19:50:45 +0300 Subject: [PATCH] Fix FileView::remote_size. GitOrigin-RevId: 0d4ad73c4459c9d3dd31676f32dc39a445802b02 --- td/telegram/cli.cpp | 2 +- td/telegram/files/FileLocation.h | 5 +++++ td/telegram/files/FileManager.cpp | 11 +++++------ 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/td/telegram/cli.cpp b/td/telegram/cli.cpp index 677095a0..e7e9d27e 100644 --- a/td/telegram/cli.cpp +++ b/td/telegram/cli.cpp @@ -3596,7 +3596,7 @@ class CliClient final : public Actor { local_size = local_size * 2 - it->size; } send_request( - make_tl_object(it->id, (it->size + it->local_size) / 2, local_size)); + make_tl_object(it->id, (it->size + 3 * it->local_size) / 4, local_size)); ++it; } } diff --git a/td/telegram/files/FileLocation.h b/td/telegram/files/FileLocation.h index eb2c2100..9c98664d 100644 --- a/td/telegram/files/FileLocation.h +++ b/td/telegram/files/FileLocation.h @@ -363,6 +363,11 @@ inline bool operator!=(const PartialRemoteFileLocation &lhs, const PartialRemote return !(lhs == rhs); } +inline StringBuilder &operator<<(StringBuilder &sb, const PartialRemoteFileLocation &location) { + return sb << '[' << (location.is_big_ ? "Big" : "Small") << " partial remote location with " << location.part_count_ + << " parts of size " << location.part_size_ << " with " << location.ready_part_count_ << " ready parts]"; +} + struct PhotoRemoteFileLocation { int64 id_; int64 access_hash_; diff --git a/td/telegram/files/FileManager.cpp b/td/telegram/files/FileManager.cpp index 35dd9ab8..479cbf48 100644 --- a/td/telegram/files/FileManager.cpp +++ b/td/telegram/files/FileManager.cpp @@ -439,7 +439,7 @@ int64 FileView::remote_size() const { return res; } default: - return 0; + return node_->remote_ready_size_; } } @@ -2349,7 +2349,7 @@ void FileManager::on_partial_upload(QueryId query_id, const PartialRemoteFileLoc auto file_id = query->file_id_; auto file_node = get_file_node(file_id); - LOG(DEBUG) << "Receive on_partial_upload for file " << file_id; + LOG(DEBUG) << "Receive on_partial_upload for file " << file_id << " with " << partial_remote; if (!file_node) { return; } @@ -2475,16 +2475,15 @@ void FileManager::on_partial_generate(QueryId query_id, const PartialLocalFileLo auto file_id = query->file_id_; auto file_node = get_file_node(file_id); - LOG(DEBUG) << "Receive on_partial_generate for file " << file_id << ": " << partial_local.path_ << " " - << Bitmask(Bitmask::Decode{}, partial_local.ready_bitmask_); + auto bitmask = Bitmask(Bitmask::Decode{}, partial_local.ready_bitmask_); + LOG(DEBUG) << "Receive on_partial_generate for file " << file_id << ": " << partial_local.path_ << " " << bitmask; if (!file_node) { return; } if (file_node->generate_id_ != query_id) { return; } - auto ready_size = Bitmask(Bitmask::Decode{}, partial_local.ready_bitmask_) - .get_total_size(partial_local.part_size_, file_node->size_); + auto ready_size = bitmask.get_total_size(partial_local.part_size_, file_node->size_); file_node->set_local_location(LocalFileLocation(partial_local), ready_size, -1, -1 /* TODO */); // TODO check for size and local_size, abort generation if needed if (expected_size > 0) {