Skip to content

Commit d699e3f

Browse files
authored
fix for uploading telegram file_name of None type (#227)
* fix for uploading telegram file_name of None type sometimes pyrogram send media.file_name as None. Bot gives Error: `[Errno 2] No such file or directory: '/home/username/mirror-bot/downloads/567/None'`
1 parent 01960db commit d699e3f

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

bot/modules/mirror.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,9 @@ def onDownloadComplete(self):
5555
download = download_dict[self.uid]
5656
name = download.name()
5757
size = download.size_raw()
58-
m_path = f'{DOWNLOAD_DIR}{self.uid}/{download.name()}'
58+
if name is None: # when pyrogram's media.file_name is of NoneType
59+
name = os.listdir(f'{DOWNLOAD_DIR}{self.uid}')[0]
60+
m_path = f'{DOWNLOAD_DIR}{self.uid}/{name}'
5961
if self.isTar:
6062
download.is_archiving = True
6163
try:

0 commit comments

Comments
 (0)