Add is_file_big function.
GitOrigin-RevId: 54b5c7eb69a005d138afbdbca8587afa3c6541cf
This commit is contained in:
parent
4cee00d938
commit
274e00175e
@ -33,8 +33,6 @@
|
||||
|
||||
namespace td {
|
||||
|
||||
constexpr int64 SMALL_FILE_MAX_SIZE = 10 * (1 << 20);
|
||||
|
||||
enum class FileType : int8 {
|
||||
Thumbnail,
|
||||
ProfilePhoto,
|
||||
@ -165,6 +163,21 @@ inline FileDirType get_file_dir_type(FileType file_type) {
|
||||
}
|
||||
}
|
||||
|
||||
inline bool is_file_big(FileType file_type, int64 expected_size) {
|
||||
switch (file_type) {
|
||||
case FileType::Thumbnail:
|
||||
case FileType::ProfilePhoto:
|
||||
case FileType::Photo:
|
||||
case FileType::EncryptedThumbnail:
|
||||
return false;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
constexpr int64 SMALL_FILE_MAX_SIZE = 10 << 20;
|
||||
return expected_size > SMALL_FILE_MAX_SIZE;
|
||||
}
|
||||
|
||||
struct FileEncryptionKey {
|
||||
enum class Type : int32 { None, Secret, Secure };
|
||||
FileEncryptionKey() = default;
|
||||
|
@ -2588,8 +2588,9 @@ void FileManager::on_error_impl(FileNodePtr node, FileManager::Query::Type type,
|
||||
if (status.message() == "FILE_PART_INVALID") {
|
||||
bool has_partial_small_location =
|
||||
node->remote_.type() == RemoteFileLocation::Type::Partial && !node->remote_.partial().is_big_;
|
||||
auto expected_size = FileView(node).expected_size(true);
|
||||
bool should_be_big_location = expected_size > SMALL_FILE_MAX_SIZE;
|
||||
FileView file_view(node);
|
||||
auto expected_size = file_view.expected_size(true);
|
||||
bool should_be_big_location = is_file_big(file_view.get_type(), expected_size);
|
||||
|
||||
node->set_remote_location(RemoteFileLocation(), FileLocationSource::None, 0);
|
||||
if (has_partial_small_location && should_be_big_location) {
|
||||
@ -2597,9 +2598,8 @@ void FileManager::on_error_impl(FileNodePtr node, FileManager::Query::Type type,
|
||||
return;
|
||||
}
|
||||
|
||||
LOG(WARNING) << "Failed to upload file: unexpected " << status << " " << has_partial_small_location << " "
|
||||
<< should_be_big_location << " "
|
||||
<< "expected size: " << expected_size;
|
||||
LOG(WARNING) << "Failed to upload file: unexpected " << status << ", is_small = " << has_partial_small_location
|
||||
<< ", should_be_big = " << should_be_big_location << ", expected size = " << expected_size;
|
||||
}
|
||||
|
||||
if (begins_with(status.message(), "FILE_GENERATE_LOCATION_INVALID")) {
|
||||
|
@ -61,7 +61,7 @@ Result<FileLoader::FileInfo> FileUploader::init() {
|
||||
offset = partial.ready_part_count_;
|
||||
} else {
|
||||
file_id_ = Random::secure_int64();
|
||||
big_flag_ = expected_size_ > SMALL_FILE_MAX_SIZE;
|
||||
big_flag_ = is_file_big(file_type_, expected_size_);
|
||||
}
|
||||
|
||||
std::vector<bool> ok(offset, true);
|
||||
|
Loading…
Reference in New Issue
Block a user