]> git.ipfire.org Git - thirdparty/paperless-ngx.git/commitdiff
Allow the user the specifiy the zip file name (#4189)
authorTrenton H <797416+stumpylog@users.noreply.github.com>
Fri, 15 Sep 2023 23:33:28 +0000 (16:33 -0700)
committerGitHub <noreply@github.com>
Fri, 15 Sep 2023 23:33:28 +0000 (16:33 -0700)
docs/administration.md
src/documents/management/commands/document_exporter.py

index 6e657447a297cc07fc08cf1e87298b343aa0843e..67efa83c5a2dd8df3546b3a2413999fac5d8278e 100644 (file)
@@ -251,14 +251,15 @@ is not a TTY" errors. For example:
 document_exporter target [-c] [-d] [-f] [-na] [-nt] [-p] [-sm] [-z]
 
 optional arguments:
--c, --compare-checksums
--d, --delete
--f, --use-filename-format
+-c,  --compare-checksums
+-d,  --delete
+-f,  --use-filename-format
 -na, --no-archive
 -nt, --no-thumbnail
--p, --use-folder-prefix
+-p,  --use-folder-prefix
 -sm, --split-manifest
--z  --zip
+-z,  --zip
+-zn, --zip-name
 ```
 
 `target` is a folder to which the data gets written. This includes
@@ -314,7 +315,8 @@ manifest.json will still contain application wide information (e.g. tags, corres
 documenttype, etc)
 
 If `-z` or `--zip` is provided, the export will be a zip file
-in the target directory, named according to the current date.
+in the target directory, named according to the current local date or the
+value set in `-zn` or `--zip-name`.
 
 !!! warning
 
index ebadafa9e711e59d5e94ff762a8a39d37da109c8..8af1c1f531d8a3f8a4da175cb3c349485385077e 100644 (file)
@@ -125,6 +125,13 @@ class Command(BaseCommand):
             help="Export the documents to a zip file in the given directory",
         )
 
+        parser.add_argument(
+            "-zn",
+            "--zip-name",
+            default=f"export-{timezone.localdate().isoformat()}",
+            help="Sets the export zip file name",
+        )
+
         parser.add_argument(
             "--no-progress-bar",
             default=False,
@@ -147,13 +154,13 @@ class Command(BaseCommand):
 
     def handle(self, *args, **options):
         self.target = Path(options["target"]).resolve()
-        self.split_manifest = options["split_manifest"]
-        self.compare_checksums = options["compare_checksums"]
-        self.use_filename_format = options["use_filename_format"]
-        self.use_folder_prefix = options["use_folder_prefix"]
-        self.delete = options["delete"]
-        self.no_archive = options["no_archive"]
-        self.no_thumbnail = options["no_thumbnail"]
+        self.split_manifest: bool = options["split_manifest"]
+        self.compare_checksums: bool = options["compare_checksums"]
+        self.use_filename_format: bool = options["use_filename_format"]
+        self.use_folder_prefix: bool = options["use_folder_prefix"]
+        self.delete: bool = options["delete"]
+        self.no_archive: bool = options["no_archive"]
+        self.no_thumbnail: bool = options["no_thumbnail"]
         zip_export: bool = options["zip"]
 
         # If zipping, save the original target for later and
@@ -189,7 +196,7 @@ class Command(BaseCommand):
                     shutil.make_archive(
                         os.path.join(
                             original_target,
-                            f"export-{timezone.localdate().isoformat()}",
+                            options["zip_name"],
                         ),
                         format="zip",
                         root_dir=temp_dir.name,