aboutsummaryrefslogtreecommitdiffstats
path: root/gallery_dl/postprocessor/compare.py
diff options
context:
space:
mode:
Diffstat (limited to 'gallery_dl/postprocessor/compare.py')
-rw-r--r--gallery_dl/postprocessor/compare.py19
1 files changed, 11 insertions, 8 deletions
diff --git a/gallery_dl/postprocessor/compare.py b/gallery_dl/postprocessor/compare.py
index 0d11844..ca416c9 100644
--- a/gallery_dl/postprocessor/compare.py
+++ b/gallery_dl/postprocessor/compare.py
@@ -16,22 +16,25 @@ class ComparePP(PostProcessor):
def __init__(self, job, options):
PostProcessor.__init__(self, job)
- if options.get("action") == "enumerate":
- self.run = self._run_enumerate
if options.get("shallow"):
- self.compare = self._compare_size
+ self._compare = self._compare_size
+ job.hooks["file"].append(
+ self.enumerate
+ if options.get("action") == "enumerate" else
+ self.compare
+ )
- def run(self, pathfmt):
+ def compare(self, pathfmt):
try:
- if self.compare(pathfmt.realpath, pathfmt.temppath):
+ if self._compare(pathfmt.realpath, pathfmt.temppath):
pathfmt.delete = True
except OSError:
pass
- def _run_enumerate(self, pathfmt):
+ def enumerate(self, pathfmt):
num = 1
try:
- while not self.compare(pathfmt.realpath, pathfmt.temppath):
+ while not self._compare(pathfmt.realpath, pathfmt.temppath):
pathfmt.prefix = str(num) + "."
pathfmt.set_extension(pathfmt.extension, False)
num += 1
@@ -39,7 +42,7 @@ class ComparePP(PostProcessor):
except OSError:
pass
- def compare(self, f1, f2):
+ def _compare(self, f1, f2):
return self._compare_size(f1, f2) and self._compare_content(f1, f2)
@staticmethod