From 2bfc3578f6e4df73da0d12fef1d3a4e5bb6fea1a Mon Sep 17 00:00:00 2001 From: levlam Date: Tue, 1 Jan 2019 20:35:08 +0300 Subject: [PATCH] Always set correct file_type in on_update_local_location. GitOrigin-RevId: b94e23635d7d975361ab1af2c5dd06fbecf62e42 --- td/telegram/files/FileLocation.h | 2 +- td/telegram/files/FileUploader.cpp | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/td/telegram/files/FileLocation.h b/td/telegram/files/FileLocation.h index dbf43409..cf01b472 100644 --- a/td/telegram/files/FileLocation.h +++ b/td/telegram/files/FileLocation.h @@ -907,7 +907,7 @@ inline bool operator!=(const FullLocalFileLocation &lhs, const FullLocalFileLoca } inline StringBuilder &operator<<(StringBuilder &sb, const FullLocalFileLocation &location) { - return sb << '[' << location.file_type_ << "] at \"" << location.path_ << '"'; + return sb << "[full local location of " << location.file_type_ << "] at \"" << location.path_ << '"'; } class LocalFileLocation { diff --git a/td/telegram/files/FileUploader.cpp b/td/telegram/files/FileUploader.cpp index 1cf90e73..094a08cd 100644 --- a/td/telegram/files/FileUploader.cpp +++ b/td/telegram/files/FileUploader.cpp @@ -122,6 +122,12 @@ Result FileUploader::on_update_local_location(const Loca file_type = location.full().file_type_; } + LOG(INFO) << "In FileUploader::on_update_local_location with " << location << ". Have path = \"" << path + << "\", local_size = " << local_size << ", local_is_ready = " << local_is_ready + << " and file type = " << file_type; + + file_type_ = file_type; + bool is_temp = false; if (encryption_key_.is_secure() && local_is_ready) { TRY_RESULT(file_fd_path, open_temp_file(FileType::Temp)); @@ -140,6 +146,7 @@ Result FileUploader::on_update_local_location(const Loca // Race: partial location could be already deleted. Just ignore such locations if (res_fd.is_error()) { if (location.type() == LocalFileLocation::Type::Partial) { + LOG(INFO) << "Ignore partial local location: " << res_fd.error(); PrefixInfo info; info.size = local_size_; info.is_ready = local_is_ready_; @@ -176,7 +183,6 @@ Result FileUploader::on_update_local_location(const Loca expected_size_ = local_size_; } local_is_ready_ = local_is_ready; - file_type_ = file_type; PrefixInfo info; info.size = local_size_;