Skip to content

Commit 04ce92b

Browse files
nasbdh9fffonion
authored andcommitted
2.024 fix task rules for empty file name (#102)
1 parent db813d7 commit 04ce92b

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

xeHentai/task.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -337,8 +337,11 @@ def rename_fname(self):
337337
done_list = set()
338338
for fid in list(self.renamed_map.keys()):
339339
fname = self.renamed_map[fid]
340+
original_ext = os.path.splitext(fname)[1]
341+
if original_ext== "":
342+
original_ext = os.path.splitext(fname)[0]
340343
# if we don't need to rename to original name and file type matches
341-
if not self.config['rename_ori'] and os.path.splitext(fname)[1].lower() == '.jpg':
344+
if not self.config['rename_ori'] and original_ext.lower() == '.jpg':
342345
continue
343346
fname_ori = os.path.join(fpath, self.get_fidpad(fid)) # id
344347
if self.config['rename_ori']:
@@ -353,7 +356,7 @@ def rename_fname(self):
353356
# will have zero knowledge about file type before scanning all per page,
354357
# thus can't determine if this id is downloaded, because file type is not
355358
# necessarily .jpg
356-
fname_to = os.path.join(fpath, self.get_fidpad(fid, os.path.splitext(fname)[1][1:]))
359+
fname_to = os.path.join(fpath, self.get_fidpad(fid, original_ext[1:]))
357360
while fname_ori != fname_to:
358361
if os.path.exists(fname_ori):
359362
while os.path.exists(fname_to):

0 commit comments

Comments
 (0)