From 89d7374272c2986e44d0eb554e239ac4349ca50f Mon Sep 17 00:00:00 2001 From: levlam Date: Wed, 8 Jan 2020 20:15:49 +0300 Subject: [PATCH] Temporarily disable CDN if streaming is enabled. GitOrigin-RevId: e6479f76a1a226d27268744421a904b4849edf17 --- td/telegram/files/FileDownloader.cpp | 6 ++++-- td/telegram/files/FileDownloader.h | 3 ++- td/telegram/files/FileLoader.cpp | 2 +- td/telegram/files/FileLoader.h | 3 ++- td/telegram/files/FileUploader.cpp | 2 +- td/telegram/files/FileUploader.h | 3 ++- 6 files changed, 12 insertions(+), 7 deletions(-) diff --git a/td/telegram/files/FileDownloader.cpp b/td/telegram/files/FileDownloader.cpp index 317b21bed..b3adea048 100644 --- a/td/telegram/files/FileDownloader.cpp +++ b/td/telegram/files/FileDownloader.cpp @@ -220,7 +220,7 @@ Result FileDownloader::should_restart_part(Part part, NetQueryPtr &net_que return false; } -Result> FileDownloader::start_part(Part part, int32 part_count) { +Result> FileDownloader::start_part(Part part, int32 part_count, int64 streaming_offset) { if (encryption_key_.is_secret()) { part.size = (part.size + 15) & ~15; // fix for last part } @@ -240,7 +240,9 @@ Result> FileDownloader::start_part(Part part, int32 int32 flags = 0; #if !TD_EMSCRIPTEN // CDN is supported, unless we use domains instead of IPs from a browser - flags |= telegram_api::upload_getFile::CDN_SUPPORTED_MASK; + if (streaming_offset == 0) { + flags |= telegram_api::upload_getFile::CDN_SUPPORTED_MASK; + } #endif DcId dc_id = remote_.is_web() ? G()->get_webfile_dc_id() : remote_.get_dc_id(); net_query = G()->net_query_creator().create( diff --git a/td/telegram/files/FileDownloader.h b/td/telegram/files/FileDownloader.h index b1b365797..4f595192a 100644 --- a/td/telegram/files/FileDownloader.h +++ b/td/telegram/files/FileDownloader.h @@ -85,7 +85,8 @@ class FileDownloader : public FileLoader { Status on_ok(int64 size) override TD_WARN_UNUSED_RESULT; void on_error(Status status) override; Result should_restart_part(Part part, NetQueryPtr &net_query) override TD_WARN_UNUSED_RESULT; - Result> start_part(Part part, int32 part_count) override TD_WARN_UNUSED_RESULT; + Result> start_part(Part part, int32 part_count, + int64 streaming_offset) override TD_WARN_UNUSED_RESULT; Result process_part(Part part, NetQueryPtr net_query) override TD_WARN_UNUSED_RESULT; void on_progress(Progress progress) override; FileLoader::Callback *get_callback() override; diff --git a/td/telegram/files/FileLoader.cpp b/td/telegram/files/FileLoader.cpp index cc2bd254d..40a6ec41b 100644 --- a/td/telegram/files/FileLoader.cpp +++ b/td/telegram/files/FileLoader.cpp @@ -194,7 +194,7 @@ Status FileLoader::do_loop() { VLOG(files) << "Start part " << tag("id", part.id) << tag("size", part.size); resource_state_.start_use(static_cast(part.size)); - TRY_RESULT(query_flag, start_part(part, parts_manager_.get_part_count())); + TRY_RESULT(query_flag, start_part(part, parts_manager_.get_part_count(), parts_manager_.get_streaming_offset())); NetQueryPtr query; bool is_blocking; std::tie(query, is_blocking) = std::move(query_flag); diff --git a/td/telegram/files/FileLoader.h b/td/telegram/files/FileLoader.h index 30fe50162..82a1697b3 100644 --- a/td/telegram/files/FileLoader.h +++ b/td/telegram/files/FileLoader.h @@ -69,7 +69,8 @@ class FileLoader : public FileLoaderActor { virtual Status before_start_parts() { return Status::OK(); } - virtual Result> start_part(Part part, int part_count) TD_WARN_UNUSED_RESULT = 0; + virtual Result> start_part(Part part, int part_count, + int64 streaming_offset) TD_WARN_UNUSED_RESULT = 0; virtual void after_start_parts() { } virtual Result process_part(Part part, NetQueryPtr net_query) TD_WARN_UNUSED_RESULT = 0; diff --git a/td/telegram/files/FileUploader.cpp b/td/telegram/files/FileUploader.cpp index 2272e439a..c4b7809f7 100644 --- a/td/telegram/files/FileUploader.cpp +++ b/td/telegram/files/FileUploader.cpp @@ -247,7 +247,7 @@ void FileUploader::after_start_parts() { try_release_fd(); } -Result> FileUploader::start_part(Part part, int32 part_count) { +Result> FileUploader::start_part(Part part, int32 part_count, int64 streaming_offset) { auto padded_size = part.size; if (encryption_key_.is_secret()) { padded_size = (padded_size + 15) & ~15; diff --git a/td/telegram/files/FileUploader.h b/td/telegram/files/FileUploader.h index f3834066d..b29118a90 100644 --- a/td/telegram/files/FileUploader.h +++ b/td/telegram/files/FileUploader.h @@ -63,7 +63,8 @@ class FileUploader : public FileLoader { void on_error(Status status) override; Status before_start_parts() override; void after_start_parts() override; - Result> start_part(Part part, int32 part_count) override TD_WARN_UNUSED_RESULT; + Result> start_part(Part part, int32 part_count, + int64 streaming_offset) override TD_WARN_UNUSED_RESULT; Result process_part(Part part, NetQueryPtr net_query) override TD_WARN_UNUSED_RESULT; void on_progress(Progress progress) override; FileLoader::Callback *get_callback() override;