diff --git a/benchmark/bench_crypto.cpp b/benchmark/bench_crypto.cpp index 222d9f56..29ceaa1d 100644 --- a/benchmark/bench_crypto.cpp +++ b/benchmark/bench_crypto.cpp @@ -30,7 +30,7 @@ class SHA1Bench : public td::Benchmark { alignas(64) unsigned char data[DATA_SIZE]; std::string get_description() const override { - return PSTRING() << "SHA1 OpenSSL [" << (DATA_SIZE >> 10) << "KB]"; + return PSTRING() << "SHA1 OpenSSL [" << (DATA_SIZE >> 10) << "kB]"; } void start_up() override { @@ -55,7 +55,7 @@ class AESBench : public td::Benchmark { td::UInt256 iv; std::string get_description() const override { - return PSTRING() << "AES OpenSSL [" << (DATA_SIZE >> 10) << "KB]"; + return PSTRING() << "AES OpenSSL [" << (DATA_SIZE >> 10) << "kB]"; } void start_up() override { @@ -152,7 +152,7 @@ class Crc32Bench : public td::Benchmark { alignas(64) unsigned char data[DATA_SIZE]; std::string get_description() const override { - return PSTRING() << "Crc32 zlib [" << (DATA_SIZE >> 10) << "KB]"; + return PSTRING() << "Crc32 zlib [" << (DATA_SIZE >> 10) << "kB]"; } void start_up() override { @@ -176,7 +176,7 @@ class Crc64Bench : public td::Benchmark { alignas(64) unsigned char data[DATA_SIZE]; std::string get_description() const override { - return PSTRING() << "Crc64 Anton [" << (DATA_SIZE >> 10) << "KB]"; + return PSTRING() << "Crc64 Anton [" << (DATA_SIZE >> 10) << "kB]"; } void start_up() override { diff --git a/td/telegram/files/FileManager.cpp b/td/telegram/files/FileManager.cpp index 19240136..7fcc5222 100644 --- a/td/telegram/files/FileManager.cpp +++ b/td/telegram/files/FileManager.cpp @@ -624,7 +624,8 @@ string FileManager::get_file_name(FileType file_type, Slice path) { } Status FileManager::check_local_location(FullLocalFileLocation &location, int64 &size) { - constexpr int64 MAX_THUMBNAIL_SIZE = 200 * (1 << 10) /* 200KB */; + constexpr int64 MAX_THUMBNAIL_SIZE = 200 * (1 << 10) /* 200 kB */; + constexpr int64 MAX_PHOTO_SIZE = 10 * (1 << 20) /* 10 MB */; if (location.path_.empty()) { return Status::Error("File must have non-empty path"); @@ -659,7 +660,11 @@ Status FileManager::check_local_location(FullLocalFileLocation &location, int64 } if ((location.file_type_ == FileType::Thumbnail || location.file_type_ == FileType::EncryptedThumbnail) && size >= MAX_THUMBNAIL_SIZE && !begins_with(PathView(location.path_).file_name(), "map")) { - return Status::Error(PSLICE() << "File \"" << location.path_ << "\" is too big for thumbnail " + return Status::Error(PSLICE() << "File \"" << location.path_ << "\" is too big for a thumbnail " + << tag("size", format::as_size(size))); + } + if (location.file_type_ == FileType::Photo && size >= MAX_PHOTO_SIZE) { + return Status::Error(PSLICE() << "File \"" << location.path_ << "\" is too big for a photo " << tag("size", format::as_size(size))); } if (size >= MAX_FILE_SIZE) { diff --git a/tdutils/td/utils/format.h b/tdutils/td/utils/format.h index 02775eee..14b13ef1 100644 --- a/tdutils/td/utils/format.h +++ b/tdutils/td/utils/format.h @@ -192,7 +192,7 @@ inline StringBuilder &operator<<(StringBuilder &logger, Size t) { uint64 value; }; - static constexpr NamedValue sizes[] = {{"B", 1}, {"KB", 1 << 10}, {"MB", 1 << 20}, {"GB", 1 << 30}}; + static constexpr NamedValue sizes[] = {{"B", 1}, {"kB", 1 << 10}, {"MB", 1 << 20}, {"GB", 1 << 30}}; static constexpr size_t sizes_n = sizeof(sizes) / sizeof(NamedValue); size_t i = 0;