From c2a873db4b2c0285a6e113d33195465ce9a109e0 Mon Sep 17 00:00:00 2001 From: levlam Date: Wed, 21 Nov 2018 13:56:14 +0300 Subject: [PATCH] Add test for decreasing local_size. GitOrigin-RevId: 4dbfd8e0ffd105cb2f87a64bc5d6c0d8112ddcc3 --- td/telegram/cli.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/td/telegram/cli.cpp b/td/telegram/cli.cpp index 6402ef6ae..90851d0be 100644 --- a/td/telegram/cli.cpp +++ b/td/telegram/cli.cpp @@ -353,6 +353,7 @@ class CliClient final : public Actor { int32 part_size = 0; int32 local_size = 0; int32 size = 0; + bool test_local_size_decrease = false; }; vector pending_file_generations_; @@ -370,6 +371,7 @@ class CliClient final : public Actor { } else { file_generation.source = update.original_path_; file_generation.part_size = to_integer(update.conversion_); + file_generation.test_local_size_decrease = !update.conversion_.empty() && update.conversion_.back() == 't'; } auto r_stat = stat(file_generation.source); @@ -3497,8 +3499,12 @@ class CliClient final : public Actor { send_request(make_tl_object(it->id, nullptr)); it = pending_file_generations_.erase(it); } else { + auto local_size = it->local_size; + if (it->test_local_size_decrease && local_size > it->size / 2) { + local_size = local_size * 2 - it->size; + } send_request( - make_tl_object(it->id, (it->size + it->local_size) / 2, it->local_size)); + make_tl_object(it->id, (it->size + it->local_size) / 2, local_size)); ++it; } }