Add can_reuse_remote_file to FileType.cpp.

This commit is contained in:
levlam 2022-04-22 14:28:51 +03:00
parent f396cadc1a
commit f76a9660ed
3 changed files with 16 additions and 4 deletions

View File

@ -2559,8 +2559,7 @@ void FileManager::resume_upload(FileId file_id, std::vector<int> bad_parts, std:
node->set_upload_pause(FileId());
}
FileView file_view(node);
if (file_view.has_active_upload_remote_location() && file_view.get_type() != FileType::Thumbnail &&
file_view.get_type() != FileType::EncryptedThumbnail && file_view.get_type() != FileType::Background) {
if (file_view.has_active_upload_remote_location() && can_reuse_remote_file(file_view.get_type())) {
LOG(INFO) << "File " << file_id << " is already uploaded";
if (callback) {
callback->on_upload_ok(file_id, nullptr);
@ -2832,8 +2831,7 @@ void FileManager::run_upload(FileNodePtr node, std::vector<int> bad_parts) {
CHECK(node->upload_id_ == 0);
if (file_view.has_alive_remote_location() && !file_view.has_active_upload_remote_location() &&
file_view.get_type() != FileType::Thumbnail && file_view.get_type() != FileType::EncryptedThumbnail &&
file_view.get_type() != FileType::Background) {
can_reuse_remote_file(file_view.get_type())) {
QueryId id = queries_container_.create(Query{file_id, Query::Type::UploadWaitFileReference});
node->upload_id_ = id;
if (node->upload_was_update_file_reference_) {

View File

@ -246,4 +246,16 @@ bool is_file_big(FileType file_type, int64 expected_size) {
return expected_size > SMALL_FILE_MAX_SIZE;
}
bool can_reuse_remote_file(FileType file_type) {
switch (file_type) {
case FileType::Thumbnail:
case FileType::EncryptedThumbnail:
case FileType::Background:
case FileType::CallLog:
return false;
default:
return true;
}
}
} // namespace td

View File

@ -63,4 +63,6 @@ FileDirType get_file_dir_type(FileType file_type);
bool is_file_big(FileType file_type, int64 expected_size);
bool can_reuse_remote_file(FileType file_type);
} // namespace td