Temporarily disable CDN if streaming is enabled.

GitOrigin-RevId: e6479f76a1a226d27268744421a904b4849edf17
This commit is contained in:
levlam 2020-01-08 20:15:49 +03:00
parent cef4c7da3f
commit 89d7374272
6 changed files with 12 additions and 7 deletions

View File

@ -220,7 +220,7 @@ Result<bool> FileDownloader::should_restart_part(Part part, NetQueryPtr &net_que
return false;
}
Result<std::pair<NetQueryPtr, bool>> FileDownloader::start_part(Part part, int32 part_count) {
Result<std::pair<NetQueryPtr, bool>> 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<std::pair<NetQueryPtr, bool>> 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(

View File

@ -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<bool> should_restart_part(Part part, NetQueryPtr &net_query) override TD_WARN_UNUSED_RESULT;
Result<std::pair<NetQueryPtr, bool>> start_part(Part part, int32 part_count) override TD_WARN_UNUSED_RESULT;
Result<std::pair<NetQueryPtr, bool>> start_part(Part part, int32 part_count,
int64 streaming_offset) override TD_WARN_UNUSED_RESULT;
Result<size_t> process_part(Part part, NetQueryPtr net_query) override TD_WARN_UNUSED_RESULT;
void on_progress(Progress progress) override;
FileLoader::Callback *get_callback() override;

View File

@ -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<int64>(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);

View File

@ -69,7 +69,8 @@ class FileLoader : public FileLoaderActor {
virtual Status before_start_parts() {
return Status::OK();
}
virtual Result<std::pair<NetQueryPtr, bool>> start_part(Part part, int part_count) TD_WARN_UNUSED_RESULT = 0;
virtual Result<std::pair<NetQueryPtr, bool>> start_part(Part part, int part_count,
int64 streaming_offset) TD_WARN_UNUSED_RESULT = 0;
virtual void after_start_parts() {
}
virtual Result<size_t> process_part(Part part, NetQueryPtr net_query) TD_WARN_UNUSED_RESULT = 0;

View File

@ -247,7 +247,7 @@ void FileUploader::after_start_parts() {
try_release_fd();
}
Result<std::pair<NetQueryPtr, bool>> FileUploader::start_part(Part part, int32 part_count) {
Result<std::pair<NetQueryPtr, bool>> 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;

View File

@ -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<std::pair<NetQueryPtr, bool>> start_part(Part part, int32 part_count) override TD_WARN_UNUSED_RESULT;
Result<std::pair<NetQueryPtr, bool>> start_part(Part part, int32 part_count,
int64 streaming_offset) override TD_WARN_UNUSED_RESULT;
Result<size_t> process_part(Part part, NetQueryPtr net_query) override TD_WARN_UNUSED_RESULT;
void on_progress(Progress progress) override;
FileLoader::Callback *get_callback() override;