From d6fb23032473f7a1404a74acb9a66c46f031b554 Mon Sep 17 00:00:00 2001 From: levlam Date: Tue, 16 Jan 2018 17:41:47 +0300 Subject: [PATCH] Add only_if_pending to cancelDownloadFile. GitOrigin-RevId: 7280c353b4903e565c2e0a2557d50317f6f7c886 --- td/generate/scheme/td_api.tl | 4 ++-- td/generate/scheme/td_api.tlo | Bin 108920 -> 108960 bytes td/telegram/Td.cpp | 2 +- td/telegram/cli.cpp | 2 +- td/telegram/files/FileManager.cpp | 7 +++++++ 5 files changed, 11 insertions(+), 4 deletions(-) diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index d370f161..f41f8b68 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -2314,8 +2314,8 @@ setPinnedChats chat_ids:vector = Ok; //@priority Priority of the download (1-32). The higher the priority, the earlier the file will be downloaded. If the priorities of two files are equal, then the last one for which downloadFile was called will be downloaded first downloadFile file_id:int32 priority:int32 = File; -//@description Stops the downloading of a file. If a file has already been downloaded, does nothing @file_id Identifier of a file to stop downloading -cancelDownloadFile file_id:int32 = Ok; +//@description Stops the downloading of a file. If a file has already been downloaded, does nothing @file_id Identifier of a file to stop downloading @only_if_pending Pass true to stop downloading only if it hasn't been started, i.e. request hasn't been sent to server +cancelDownloadFile file_id:int32 only_if_pending:Bool = Ok; //@description Asynchronously uploads a file to the cloud without sending it in a message. updateFile will be used to notify about upload progress and successful completion of the upload. The file will not have a persistent remote identifier until it will be sent in a message @file File to upload @file_type File type //@priority Priority of the upload (1-32). The higher the priority, the earlier the file will be uploaded. If the priorities of two files are equal, then the first one for which uploadFile was called will be uploaded first diff --git a/td/generate/scheme/td_api.tlo b/td/generate/scheme/td_api.tlo index ef1811c140d5352ab338b7a666cf338478c59600..5205431538c2ba1c2582efc23ba8535a108fe459 100644 GIT binary patch delta 54 zcmexyiEY7UwuUW?ELJS{f*QJ~b67FTOlR?7)DYm$&&#Qd&rFLiNX<*h%uAo{;J~P} KJ;91mA|C)A4-#?! delta 32 ocmZ2*neE3VwuUW?ELJRv`F=O2b67FTOkZKeXtTY;icumT0L;+~B>(^b diff --git a/td/telegram/Td.cpp b/td/telegram/Td.cpp index 5a6db518..304f9996 100644 --- a/td/telegram/Td.cpp +++ b/td/telegram/Td.cpp @@ -5568,7 +5568,7 @@ void Td::on_request(uint64 id, const td_api::downloadFile &request) { void Td::on_request(uint64 id, const td_api::cancelDownloadFile &request) { CHECK_AUTH(); - file_manager_->download(FileId(request.file_id_), nullptr, 0); + file_manager_->download(FileId(request.file_id_), nullptr, request.only_if_pending_ ? -1 : 0); send_closure(actor_id(this), &Td::send_result, id, make_tl_object()); } diff --git a/td/telegram/cli.cpp b/td/telegram/cli.cpp index 17282005..d8375047 100644 --- a/td/telegram/cli.cpp +++ b/td/telegram/cli.cpp @@ -1796,7 +1796,7 @@ class CliClient final : public Actor { send_request(make_tl_object(i, to_integer(priority))); } } else if (op == "cdf") { - send_request(make_tl_object(as_file_id(args))); + send_request(make_tl_object(as_file_id(args), true)); } else if (op == "uf") { string file_path; string priority; diff --git a/td/telegram/files/FileManager.cpp b/td/telegram/files/FileManager.cpp index 11bcdb7b..14fd368f 100644 --- a/td/telegram/files/FileManager.cpp +++ b/td/telegram/files/FileManager.cpp @@ -1339,6 +1339,13 @@ void FileManager::download(FileId file_id, std::shared_ptr cal return; } + if (new_priority == -1) { + if (node->is_download_started_) { + return; + } + new_priority = 0; + } + auto *file_info = get_file_id_info(file_id); CHECK(new_priority == 0 || callback); file_info->download_priority_ = new_priority;