mirror of
https://github.com/mikf/gallery-dl.git
synced 2024-11-26 04:32:51 +01:00
fix crash when using 'skip=false' and archive (fixes #1023)
Separating the archive check from pathfmt.exists() in b5243297
had some unintended side effects.
It is also not possible to monkey-patch a dunder method like
__contains__ because of the special method lookup that gets
performed for them.
This commit is contained in:
parent
aeb0d32333
commit
d5fa716d89
@ -228,7 +228,7 @@ class DownloadJob(Job):
|
||||
for pp in postprocessors:
|
||||
pp.prepare(pathfmt)
|
||||
|
||||
if archive and kwdict in archive:
|
||||
if archive and archive.check(kwdict):
|
||||
pathfmt.fix_extension()
|
||||
self.handle_skip()
|
||||
return
|
||||
@ -385,8 +385,23 @@ class DownloadJob(Job):
|
||||
|
||||
self.sleep = config("sleep")
|
||||
if not config("download", True):
|
||||
# monkey-patch method to do nothing and always return True
|
||||
self.download = pathfmt.fix_extension
|
||||
|
||||
archive = config("archive")
|
||||
if archive:
|
||||
path = util.expand_path(archive)
|
||||
try:
|
||||
if "{" in path:
|
||||
path = util.Formatter(path).format_map(kwdict)
|
||||
self.archive = util.DownloadArchive(path, self.extractor)
|
||||
except Exception as exc:
|
||||
self.extractor.log.warning(
|
||||
"Failed to open download archive at '%s' ('%s: %s')",
|
||||
path, exc.__class__.__name__, exc)
|
||||
else:
|
||||
self.extractor.log.debug("Using download archive '%s'", path)
|
||||
|
||||
skip = config("skip", True)
|
||||
if skip:
|
||||
self._skipexc = None
|
||||
@ -401,21 +416,10 @@ class DownloadJob(Job):
|
||||
self._skipcnt = 0
|
||||
self._skipmax = text.parse_int(smax)
|
||||
else:
|
||||
# monkey-patch methods to always return False
|
||||
pathfmt.exists = lambda x=None: False
|
||||
|
||||
archive = config("archive")
|
||||
if archive:
|
||||
path = util.expand_path(archive)
|
||||
try:
|
||||
if "{" in path:
|
||||
path = util.Formatter(path).format_map(kwdict)
|
||||
self.archive = util.DownloadArchive(path, self.extractor)
|
||||
except Exception as exc:
|
||||
self.extractor.log.warning(
|
||||
"Failed to open download archive at '%s' ('%s: %s')",
|
||||
path, exc.__class__.__name__, exc)
|
||||
else:
|
||||
self.extractor.log.debug("Using download archive '%s'", path)
|
||||
if self.archive:
|
||||
self.archive.check = pathfmt.exists
|
||||
|
||||
postprocessors = self.extractor.config_accumulate("postprocessors")
|
||||
if postprocessors:
|
||||
|
@ -941,7 +941,7 @@ class DownloadArchive():
|
||||
"archive-format", extractor.archive_fmt)
|
||||
).format_map
|
||||
|
||||
def __contains__(self, kwdict):
|
||||
def check(self, kwdict):
|
||||
"""Return True if the item described by 'kwdict' exists in archive"""
|
||||
key = kwdict["_archive_key"] = self.keygen(kwdict)
|
||||
self.cursor.execute(
|
||||
|
Loading…
Reference in New Issue
Block a user