Skip to content

Commit 88e15fa

Browse files
committed
fix file renaming after task completion
1 parent 43fc55c commit 88e15fa

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

xeHentai/task.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,17 +271,23 @@ def save_file(self, imgurl, redirect_url, binary_iter):
271271
pass
272272
else:
273273
raise ex
274+
275+
# Store the actual downloaded file name and its extension
276+
actual_ext = os.path.splitext(fname)[1] or '.jpg' # Default to .jpg if no extension
277+
self.renamed_map[fid] = fname # Store the complete filename for renaming later
278+
274279
self.set_fid_finished(fid)
275280
if fid in self.duplicate_map:
276281
for fid_rep in self.duplicate_map[fid]:
277282
# if a file download is interrupted, it will appear in self.filehash_map as well
278283
if fid_rep == fid:
279284
continue
280-
fn_rep = os.path.join(fpath, self.get_fidpad(fid_rep))
285+
fn_rep = os.path.join(fpath, self.get_fidpad(fid_rep, actual_ext[1:])) # Use actual_ext here
281286
shutil.copyfile(fn, fn_rep)
282287
self.set_fid_finished(fid_rep)
283288
self.logger.debug("#%s is copied from #%s in save_file" % (fid_rep, fid))
284289
del self.duplicate_map[fid]
290+
285291
except Exception as ex:
286292
self._f_lock.release()
287293
raise ex

0 commit comments

Comments
 (0)