Skip to content

Commit

Permalink
2.019 fix some cases when monitor exits too early
Browse files Browse the repository at this point in the history
  • Loading branch information
fffonion committed Feb 25, 2018
1 parent 2c022fd commit 12c2cf2
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions xeHentai/task.py
Expand Up @@ -199,9 +199,6 @@ def save_file(self, imgurl, redirect_url, binary_iter):
fn = os.path.join(fpath, self.get_fidpad(int(fid)))
if os.path.exists(fn) and os.stat(fn).st_size > 0:
return fn
self._cnt_lock.acquire()
self.meta['finished'] += 1
self._cnt_lock.release()
# create a femp file first
# we don't need _f_lock because this will not be in a sequence
# and we can't do that otherwise we are breaking the multi threading
Expand All @@ -215,6 +212,10 @@ def save_file(self, imgurl, redirect_url, binary_iter):
except DownloadAbortedException as ex:
os.remove(fn_tmp)
return
self._cnt_lock.acquire()
self.meta['finished'] += 1
self._cnt_lock.release()

self._f_lock.acquire()
try:
os.rename(fn_tmp, fn)
Expand Down

0 comments on commit 12c2cf2

Please sign in to comment.