mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-07-28 18:24:38 -05:00
add prefix option to administration exporter
This commit is contained in:

committed by
Trenton H

parent
42d4550d9c
commit
44d8bd3151
@@ -72,6 +72,15 @@ class Command(BaseCommand):
|
||||
"export directory, if configured.",
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
"-p",
|
||||
"--use-filename-prefix",
|
||||
default=False,
|
||||
action="store_true",
|
||||
help="Export files in dedicated folders according to their nature: "
|
||||
"archive, originals or thumbnails",
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
"-d",
|
||||
"--delete",
|
||||
@@ -97,6 +106,7 @@ class Command(BaseCommand):
|
||||
action="store_true",
|
||||
help="Avoid exporting thumbnail files",
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
"--no-progress-bar",
|
||||
default=False,
|
||||
@@ -119,6 +129,7 @@ class Command(BaseCommand):
|
||||
self.exported_files: List[Path] = []
|
||||
self.compare_checksums = False
|
||||
self.use_filename_format = False
|
||||
self.use_filename_prefix = False
|
||||
self.delete = False
|
||||
self.no_archive = False
|
||||
self.no_thumbnail = False
|
||||
@@ -128,6 +139,7 @@ class Command(BaseCommand):
|
||||
self.target = Path(options["target"]).resolve()
|
||||
self.compare_checksums = options["compare_checksums"]
|
||||
self.use_filename_format = options["use_filename_format"]
|
||||
self.use_filename_prefix = options["use_filename_prefix"]
|
||||
self.delete = options["delete"]
|
||||
self.no_archive = options["no_archive"]
|
||||
self.no_thumbnail = options["no_thumbnail"]
|
||||
@@ -262,11 +274,15 @@ class Command(BaseCommand):
|
||||
|
||||
# 3.3. write filenames into manifest
|
||||
original_name = base_name
|
||||
if self.use_filename_prefix:
|
||||
original_name = ("originals" / Path(original_name)).resolve()
|
||||
original_target = (self.target / Path(original_name)).resolve()
|
||||
document_dict[EXPORTER_FILE_NAME] = original_name
|
||||
|
||||
if not self.no_thumbnail:
|
||||
thumbnail_name = base_name + "-thumbnail.webp"
|
||||
if self.use_filename_prefix:
|
||||
thumbnail_name = ("thumbnails" / Path(thumbnail_name)).resolve()
|
||||
thumbnail_target = (self.target / Path(thumbnail_name)).resolve()
|
||||
document_dict[EXPORTER_THUMBNAIL_NAME] = thumbnail_name
|
||||
else:
|
||||
@@ -274,6 +290,8 @@ class Command(BaseCommand):
|
||||
|
||||
if not self.no_archive and document.has_archive_version:
|
||||
archive_name = base_name + "-archive.pdf"
|
||||
if self.use_filename_prefix:
|
||||
archive_name = ("archive" / Path(archive_name)).resolve()
|
||||
archive_target = (self.target / Path(archive_name)).resolve()
|
||||
document_dict[EXPORTER_ARCHIVE_NAME] = archive_name
|
||||
else:
|
||||
|
Reference in New Issue
Block a user