Update file.size to reflect the size of the largest thumbnail

This way we avoid relying on the order of the thumbnails, and just
pick the largest.
This commit is contained in:
Lonami Exo 2021-02-13 22:52:27 +01:00
parent b102f1f345
commit ff3c21c805

View File

@ -120,9 +120,11 @@ class File:
def size(self):
"""
The size in bytes of this file.
For photos, this is the heaviest thumbnail, as it often repressents the largest dimensions.
"""
if isinstance(self.media, types.Photo):
return utils._photo_size_byte_count(self.media.sizes[-1])
return max(filter(None, map(utils._photo_size_byte_count, self.media.sizes)), default=None)
elif isinstance(self.media, types.Document):
return self.media.size