Delete only temporary partially generated files.

GitOrigin-RevId: aa4f17ddf141fd2058b8345126e936256609b10a
This commit is contained in:
levlam 2018-12-28 19:54:46 +03:00
parent 5a741ce08d
commit ded974762a

View File

@ -5,7 +5,6 @@
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // 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/files/FileManager.h"
#include "td/telegram/telegram_api.h" #include "td/telegram/telegram_api.h"
#include "td/telegram/ConfigShared.h" #include "td/telegram/ConfigShared.h"
@ -2590,10 +2589,14 @@ void FileManager::on_error_impl(FileNodePtr node, FileManager::Query::Type type,
if (status.code() == 0) { if (status.code() == 0) {
// Remove partial locations // Remove partial locations
if (node->local_.type() == LocalFileLocation::Type::Partial && status.message() != "FILE_UPLOAD_RESTART") { if (node->local_.type() == LocalFileLocation::Type::Partial && status.message() != "FILE_UPLOAD_RESTART") {
LOG(INFO) << "Unlink file " << node->local_.partial().path_; CSlice path = node->local_.partial().path_;
unlink(node->local_.partial().path_).ignore(); 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(); node->drop_local_location();
} }
}
if (node->remote_.type() == RemoteFileLocation::Type::Partial) { if (node->remote_.type() == RemoteFileLocation::Type::Partial) {
node->set_remote_location(RemoteFileLocation(), FileLocationSource::None, 0); node->set_remote_location(RemoteFileLocation(), FileLocationSource::None, 0);
} }