Skip to content

Commit

Permalink
2.022 handle rename in duplicate file better
Browse files Browse the repository at this point in the history
  • Loading branch information
fffonion committed Mar 26, 2020
1 parent 23fae73 commit d7dcf0f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion xeHentai/rpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ def _get_image_path(self, guid, fid):
if guid not in self._all_tasks:
return None, None, None
t = self._all_tasks[guid]
fid = str(fid)
fid = int(fid)
if fid in t.renamed_map:
f = t.renamed_map[fid]
else:
Expand Down
7 changes: 4 additions & 3 deletions xeHentai/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,13 @@ def put_img_queue(self, imgurl, reload_url, fname):
img_hash = RE_GALLERY.findall(reload_url)[0][0]
else:
img_hash = self.get_imghash(imgurl)
this_fid = int(RE_GALLERY.findall(reload_url)[0][1])
self.renamed_map[this_fid] = fname
# if same file occurs severl times in a gallery
while img_hash in self.reload_map:
fpath = self.get_fpath()
old_fid = self.get_fname(img_hash)[0]
old_f = os.path.join(fpath, self.get_fidpad(old_fid))
this_fid = int(RE_GALLERY.findall(reload_url)[0][1])
this_f = os.path.join(fpath, self.get_fidpad(this_fid))
self._f_lock.acquire()
# if we are equal to ourself, download as usual
Expand Down Expand Up @@ -325,8 +326,8 @@ def rename_fname(self):
# whether to rename into a temp filename or add (1)
# only need it when rename_ori = True
done_list = set()
for h in self.reload_map:
fid, fname = self.get_fname(h)
for fid in self.renamed_map.keys():
fname = self.renamed_map[fid]
# if we don't need to rename to original name and file type matches
if not self.config['rename_ori'] and os.path.splitext(fname)[1].lower() == '.jpg':
continue
Expand Down

0 comments on commit d7dcf0f

Please sign in to comment.