@@ -318,33 +318,35 @@ Result<FullLocalLocationInfo> check_full_local_location(FullLocalLocationInfo lo
318
318
} else if (!are_modification_times_equal (location.mtime_nsec_ , stat.mtime_nsec_ )) {
319
319
VLOG (file_loader) << " File \" " << location.path_ << " \" was modified: old mtime = " << location.mtime_nsec_
320
320
<< " , new mtime = " << stat.mtime_nsec_ ;
321
- return Status::Error (400 , PSLICE () << " File \" " << utf8_encode (location. path_ ) << " \" was modified" );
321
+ return Status::Error (400 , " File was modified" );
322
322
}
323
323
if (skip_file_size_checks) {
324
324
return std::move (local_info);
325
325
}
326
326
327
- auto get_file_size_error = [&](Slice reason) {
328
- return Status::Error (400 , PSLICE () << " File \" " << utf8_encode (location. path_ ) << " \" of size " << size
329
- << " bytes is too big " << reason );
327
+ auto get_file_size_error = [&](Slice reason, int64 max_size ) {
328
+ return Status::Error (400 , PSLICE () << " File of size " << size << " bytes is too big " << reason
329
+ << " ; the maximum size is " << max_size << " bytes " );
330
330
};
331
331
if ((location.file_type_ == FileType::Thumbnail || location.file_type_ == FileType::EncryptedThumbnail) &&
332
332
size > MAX_THUMBNAIL_SIZE && !begins_with (PathView (location.path_ ).file_name (), " map" ) &&
333
333
!begins_with (PathView (location.path_ ).file_name (), " Album cover for " )) {
334
- return get_file_size_error (" for a thumbnail" );
334
+ return get_file_size_error (" for a thumbnail" , MAX_THUMBNAIL_SIZE );
335
335
}
336
336
if (size > MAX_FILE_SIZE) {
337
- return get_file_size_error (" " );
337
+ return get_file_size_error (" " , MAX_FILE_SIZE );
338
338
}
339
339
if (get_file_type_class (location.file_type_ ) == FileTypeClass::Photo && size > MAX_PHOTO_SIZE) {
340
- return get_file_size_error (" for a photo" );
340
+ return get_file_size_error (" for a photo" , MAX_PHOTO_SIZE );
341
341
}
342
- if ((location.file_type_ == FileType::VideoNote || location.file_type_ == FileType::SelfDestructingVideoNote) &&
343
- size > G ()->get_option_integer (" video_note_size_max" , DEFAULT_VIDEO_NOTE_SIZE_MAX)) {
344
- return get_file_size_error (" for a video note" );
342
+ if (location.file_type_ == FileType::VideoNote || location.file_type_ == FileType::SelfDestructingVideoNote) {
343
+ auto max_size = G ()->get_option_integer (" video_note_size_max" , DEFAULT_VIDEO_NOTE_SIZE_MAX);
344
+ if (size > max_size) {
345
+ return get_file_size_error (" for a video note" , max_size);
346
+ }
345
347
}
346
348
if (location.file_type_ == FileType::VideoStory && size > MAX_VIDEO_STORY_SIZE) {
347
- return get_file_size_error (" for a video story" );
349
+ return get_file_size_error (" for a video story" , MAX_VIDEO_STORY_SIZE );
348
350
}
349
351
return std::move (local_info);
350
352
}
0 commit comments