Use message.document.size instead of size_limit in case if the uploaded file is a bit smaller

This commit is contained in:
blank X 2021-04-07 23:41:14 +07:00
parent b980e90068
commit 02ad4d6d6b
Signed by: blankie
GPG Key ID: CC15FC822C7F61F5
1 changed files with 3 additions and 3 deletions

View File

@ -234,10 +234,10 @@ async def _upload_worker():
if is_big:
file.name = f'{base_filename}.part{str(files_sent).rjust(2, "0")}'
messages.append((await client.send_message(config['config']['storage_chat_id'], f'Uploading {file.name}...', parse_mode=None)).id)
await client.send_file(config['config']['storage_chat_id'], file, caption=file.name, parse_mode=None)
total_size -= size_limit
message = await client.send_file(config['config']['storage_chat_id'], file, caption=file.name, parse_mode=None)
total_size -= message.document.size
if total_size > 0:
size_sent += size_limit
size_sent += message.document.size
files_sent += 1
file = bopen(video_filename, size_limit, None)
if messages: