diff --git a/docs/administration.md b/docs/administration.md index a8009c85e..db29f3268 100644 --- a/docs/administration.md +++ b/docs/administration.md @@ -233,6 +233,7 @@ optional arguments: -c, --compare-checksums -f, --use-filename-format -d, --delete +-z --zip ``` `target` is a folder to which the data gets written. This includes @@ -258,6 +259,9 @@ current export such as files from deleted documents, specify `--delete`. Be careful when pointing paperless to a directory that already contains other files. +If `-z` or `--zip` is provided, the export will be a zipfile +in the target directory, named according to the current date. + The filenames generated by this command follow the format `[date created] [correspondent] [title].[extension]`. If you want paperless to use `PAPERLESS_FILENAME_FORMAT` for exported filenames diff --git a/src/documents/tests/test_management_exporter.py b/src/documents/tests/test_management_exporter.py index fd9c9366d..a24b292d7 100644 --- a/src/documents/tests/test_management_exporter.py +++ b/src/documents/tests/test_management_exporter.py @@ -370,6 +370,15 @@ class TestExportImport(DirectoriesMixin, TestCase): @override_settings(PASSPHRASE="test") def test_export_zipped(self): + """ + GIVEN: + - Request to export documents to zipfile + WHEN: + - Documents are exported + THEN: + - Zipfile is created + - Zipfile contains exported files + """ shutil.rmtree(os.path.join(self.dirs.media_dir, "documents")) shutil.copytree( os.path.join(os.path.dirname(__file__), "samples", "documents"), @@ -394,6 +403,16 @@ class TestExportImport(DirectoriesMixin, TestCase): @override_settings(PASSPHRASE="test") def test_export_zipped_format(self): + """ + GIVEN: + - Request to export documents to zipfile + - Export is following filename formatting + WHEN: + - Documents are exported + THEN: + - Zipfile is created + - Zipfile contains exported files + """ shutil.rmtree(os.path.join(self.dirs.media_dir, "documents")) shutil.copytree( os.path.join(os.path.dirname(__file__), "samples", "documents"), @@ -415,7 +434,6 @@ class TestExportImport(DirectoriesMixin, TestCase): self.assertTrue(os.path.isfile(expected_file)) with ZipFile(expected_file) as zip: - print(zip.namelist()) # Extras are from the directories, which also appear in the listing self.assertEqual(len(zip.namelist()), 14) self.assertIn("manifest.json", zip.namelist())