diff --git a/td/telegram/files/FileDownloader.cpp b/td/telegram/files/FileDownloader.cpp index 924321ff..9115e02e 100644 --- a/td/telegram/files/FileDownloader.cpp +++ b/td/telegram/files/FileDownloader.cpp @@ -21,6 +21,7 @@ #include "td/utils/port/Stat.h" #include "td/utils/ScopeGuard.h" #include "td/utils/Slice.h" +#include "td/utils/port/path.h" #include @@ -117,6 +118,7 @@ Status FileDownloader::on_ok(int64 size) { string tmp_path; std::tie(std::ignore, tmp_path) = std::move(file_path); TRY_STATUS(secure_storage::decrypt_file(encryption_key_.secret(), encryption_key_.value_hash(), path_, tmp_path)); + unlink(path_).ignore(); path_ = std::move(tmp_path); TRY_RESULT(path_stat, stat(path_)); size = path_stat.size_; diff --git a/td/telegram/files/FileUploader.cpp b/td/telegram/files/FileUploader.cpp index d583b8f7..7fb238ba 100644 --- a/td/telegram/files/FileUploader.cpp +++ b/td/telegram/files/FileUploader.cpp @@ -123,6 +123,7 @@ Result FileUploader::on_update_local_location(const Loca TRY_RESULT(hash, secure_storage::encrypt_file(encryption_key_.secret(), path, new_path)); LOG(INFO) << "ENCRYPT " << path << " " << new_path; callback_->on_hash(hash.as_slice().str()); + unlink(path).ignore(); path = new_path; is_temp = true; }