From ded974762aba8629af880381bc769259b4fa9a65 Mon Sep 17 00:00:00 2001 From: levlam Date: Fri, 28 Dec 2018 19:54:46 +0300 Subject: [PATCH] Delete only temporary partially generated files. GitOrigin-RevId: aa4f17ddf141fd2058b8345126e936256609b10a --- td/telegram/files/FileManager.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/td/telegram/files/FileManager.cpp b/td/telegram/files/FileManager.cpp index 94610861..8d5f3b63 100644 --- a/td/telegram/files/FileManager.cpp +++ b/td/telegram/files/FileManager.cpp @@ -5,7 +5,6 @@ // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // #include "td/telegram/files/FileManager.h" - #include "td/telegram/telegram_api.h" #include "td/telegram/ConfigShared.h" @@ -2590,9 +2589,13 @@ void FileManager::on_error_impl(FileNodePtr node, FileManager::Query::Type type, if (status.code() == 0) { // Remove partial locations if (node->local_.type() == LocalFileLocation::Type::Partial && status.message() != "FILE_UPLOAD_RESTART") { - LOG(INFO) << "Unlink file " << node->local_.partial().path_; - unlink(node->local_.partial().path_).ignore(); - node->drop_local_location(); + CSlice path = node->local_.partial().path_; + if (begins_with(path, get_files_temp_dir(FileType::Encrypted)) || + begins_with(path, get_files_temp_dir(FileType::Video))) { + LOG(INFO) << "Unlink file " << path; + unlink(path).ignore(); + node->drop_local_location(); + } } if (node->remote_.type() == RemoteFileLocation::Type::Partial) { node->set_remote_location(RemoteFileLocation(), FileLocationSource::None, 0);