[archive] add 'archive-mode' option (#5255)
This commit is contained in:
@@ -844,6 +844,22 @@ Description
|
|||||||
An alternative `format string`_ to build archive IDs with.
|
An alternative `format string`_ to build archive IDs with.
|
||||||
|
|
||||||
|
|
||||||
|
extractor.*.archive-mode
|
||||||
|
------------------------
|
||||||
|
Type
|
||||||
|
``string``
|
||||||
|
Default
|
||||||
|
``"file"``
|
||||||
|
Description
|
||||||
|
Controls when to write `archive IDs <extractor.*.archive-format_>`__
|
||||||
|
to the archive database.
|
||||||
|
|
||||||
|
* ``"file"``: Write IDs immediately
|
||||||
|
after completing or skipping a file download.
|
||||||
|
* ``"memory"``: Keep IDs in memory
|
||||||
|
and only write them after successful job completion.
|
||||||
|
|
||||||
|
|
||||||
extractor.*.archive-prefix
|
extractor.*.archive-prefix
|
||||||
--------------------------
|
--------------------------
|
||||||
Type
|
Type
|
||||||
@@ -6172,7 +6188,7 @@ Description
|
|||||||
|
|
||||||
* format
|
* format
|
||||||
* General format string for logging messages
|
* General format string for logging messages
|
||||||
or a dictionary with format strings for each loglevel.
|
or an ``object`` with format strings for each loglevel.
|
||||||
|
|
||||||
In addition to the default
|
In addition to the default
|
||||||
`LogRecord attributes <https://docs.python.org/3/library/logging.html#logrecord-attributes>`__,
|
`LogRecord attributes <https://docs.python.org/3/library/logging.html#logrecord-attributes>`__,
|
||||||
|
|||||||
@@ -436,6 +436,8 @@ class DownloadJob(Job):
|
|||||||
|
|
||||||
def handle_finalize(self):
|
def handle_finalize(self):
|
||||||
if self.archive:
|
if self.archive:
|
||||||
|
if not self.status:
|
||||||
|
self.archive.finalize()
|
||||||
self.archive.close()
|
self.archive.close()
|
||||||
|
|
||||||
pathfmt = self.pathfmt
|
pathfmt = self.pathfmt
|
||||||
@@ -530,7 +532,11 @@ class DownloadJob(Job):
|
|||||||
if "{" in archive_path:
|
if "{" in archive_path:
|
||||||
archive_path = formatter.parse(
|
archive_path = formatter.parse(
|
||||||
archive_path).format_map(kwdict)
|
archive_path).format_map(kwdict)
|
||||||
self.archive = archive.DownloadArchive(
|
if cfg("archive-mode") == "memory":
|
||||||
|
archive_cls = archive.DownloadArchiveMemory
|
||||||
|
else:
|
||||||
|
archive_cls = archive.DownloadArchive
|
||||||
|
self.archive = archive_cls(
|
||||||
archive_path, archive_format, archive_pragma)
|
archive_path, archive_format, archive_pragma)
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
extr.log.warning(
|
extr.log.warning(
|
||||||
|
|||||||
Reference in New Issue
Block a user