From 12c2cf2f1dd6fa26d4c9aea18ed881799c9a78d7 Mon Sep 17 00:00:00 2001 From: Alliumcepa Date: Sun, 25 Feb 2018 00:18:36 -0500 Subject: [PATCH] 2.019 fix some cases when monitor exits too early --- xeHentai/task.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/xeHentai/task.py b/xeHentai/task.py index dcdd9b7..663ec04 100644 --- a/xeHentai/task.py +++ b/xeHentai/task.py @@ -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 @@ -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)