mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-08-08 21:10:29 +00:00
Always cache files smaller than 10MB, now in the database
This removes the need for a .clear_cache() method as now files are identified by their MD5 (which needs to be calculated always) and their file size (to make collisions even more unlikely) instead using the file path (which can now change).
This commit is contained in:
@@ -759,13 +759,8 @@ class TelegramClient(TelegramBareClient):
|
||||
for ext in ('.png', '.jpg', '.gif', '.jpeg')
|
||||
)
|
||||
|
||||
file_hash = hash(file)
|
||||
if file_hash in self._upload_cache:
|
||||
file_handle = self._upload_cache[file_hash]
|
||||
else:
|
||||
self._upload_cache[file_hash] = file_handle = self.upload_file(
|
||||
file, progress_callback=progress_callback
|
||||
)
|
||||
file_handle = self.upload_file(
|
||||
file, progress_callback=progress_callback)
|
||||
|
||||
if as_photo and not force_document:
|
||||
media = InputMediaUploadedPhoto(file_handle, caption)
|
||||
@@ -835,14 +830,6 @@ class TelegramClient(TelegramBareClient):
|
||||
reply_to=reply_to,
|
||||
is_voice_note=()) # empty tuple is enough
|
||||
|
||||
def clear_file_cache(self):
|
||||
"""Calls to .send_file() will cache the remote location of the
|
||||
uploaded files so that subsequent files can be immediate, so
|
||||
uploading the same file path will result in using the cached
|
||||
version. To avoid this a call to this method should be made.
|
||||
"""
|
||||
self._upload_cache.clear()
|
||||
|
||||
# endregion
|
||||
|
||||
# region Downloading media requests
|
||||
|
Reference in New Issue
Block a user