A community-supported supercharged document management system: scan, index and archive all your documents
Python aiangulararchivingdjangodmsdocument-managementdocument-management-systemllmmachine-learningocroptical-character-recognitionpdf
replace --use-filename-prefix with --use-folder-prefix
Matthieu Helleboid02a40055f506
diff --git a/docs/administration.md b/docs/administration.mdindex 4e35d67fb..b4bd6fab6 100644--- a/docs/administration.md+++ b/docs/administration.md@@ -235,7 +235,7 @@ optional arguments:-f, --use-filename-format-na, --no-archive-nt, --no-thumbnail--p, --use-filename-prefix+-p, --use-folder-prefix-sm, --split-manifest-z --zip```@@ -283,7 +283,7 @@ If `-nt` or `--no-thumbnail` is provided, thumbnail files will not be exported.can change (new archiver algorithm) and may then cause additional used space ina deduplicated backup.-If `-p` or `--use-filename-prefix` is provided, files will be exported+If `-p` or `--use-folder-prefix` is provided, files will be exportedin dedicated folders according to their nature: `archive`, `originals`,`thumbnails` or `json`diff --git a/src/documents/management/commands/document_exporter.py b/src/documents/management/commands/document_exporter.pyindex 2e8c08a38..8e8a4978c 100644--- a/src/documents/management/commands/document_exporter.py+++ b/src/documents/management/commands/document_exporter.py@@ -100,7 +100,7 @@ class Command(BaseCommand):parser.add_argument("-p",- "--use-filename-prefix",+ "--use-folder-prefix",default=False,action="store_true",help="Export files in dedicated folders according to their nature: "@@ -138,7 +138,7 @@ class Command(BaseCommand):self.exported_files: List[Path] = []self.compare_checksums = Falseself.use_filename_format = False- self.use_filename_prefix = False+ self.use_folder_prefix = Falseself.delete = Falseself.no_archive = Falseself.no_thumbnail = False@@ -149,7 +149,7 @@ class Command(BaseCommand):self.split_manifest = options["split_manifest"]self.compare_checksums = options["compare_checksums"]self.use_filename_format = options["use_filename_format"]- self.use_filename_prefix = options["use_filename_prefix"]+ self.use_folder_prefix = options["use_folder_prefix"]self.delete = options["delete"]self.no_archive = options["no_archive"]self.no_thumbnail = options["no_thumbnail"]@@ -287,14 +287,14 @@ class Command(BaseCommand):# 3.3. write filenames into manifestoriginal_name = base_name- if self.use_filename_prefix:+ if self.use_folder_prefix:original_name = os.path.join("originals", original_name)original_target = (self.target / Path(original_name)).resolve()document_dict[EXPORTER_FILE_NAME] = original_nameif not self.no_thumbnail:thumbnail_name = base_name + "-thumbnail.webp"- if self.use_filename_prefix:+ if self.use_folder_prefix:thumbnail_name = os.path.join("thumbnails", thumbnail_name)thumbnail_target = (self.target / Path(thumbnail_name)).resolve()document_dict[EXPORTER_THUMBNAIL_NAME] = thumbnail_name@@ -303,7 +303,7 @@ class Command(BaseCommand):if not self.no_archive and document.has_archive_version:archive_name = base_name + "-archive.pdf"- if self.use_filename_prefix:+ if self.use_folder_prefix:archive_name = os.path.join("archive", archive_name)archive_target = (self.target / Path(archive_name)).resolve()document_dict[EXPORTER_ARCHIVE_NAME] = archive_name@@ -349,7 +349,7 @@ class Command(BaseCommand):if self.split_manifest:manifest_name = base_name + "-manifest.json"- if self.use_filename_prefix:+ if self.use_folder_prefix:manifest_name = os.path.join("json", manifest_name)manifest_name = (self.target / Path(manifest_name)).resolve()manifest_name.parent.mkdir(parents=True, exist_ok=True)diff --git a/src/documents/tests/test_management_exporter.py b/src/documents/tests/test_management_exporter.pyindex d9b5a6dd2..0d815a602 100644--- a/src/documents/tests/test_management_exporter.py+++ b/src/documents/tests/test_management_exporter.py@@ -105,7 +105,7 @@ class TestExportImport(DirectoriesMixin, TestCase):no_archive=False,no_thumbnail=False,split_manifest=False,- use_filename_prefix=False,+ use_folder_prefix=False,):args = ["document_exporter", self.target]if use_filename_format:@@ -120,8 +120,8 @@ class TestExportImport(DirectoriesMixin, TestCase):args += ["--no-thumbnail"]if split_manifest:args += ["--split-manifest"]- if use_filename_prefix:- args += ["--use-filename-prefix"]+ if use_folder_prefix:+ args += ["--use-folder-prefix"]call_command(*args)@@ -623,12 +623,12 @@ class TestExportImport(DirectoriesMixin, TestCase):call_command("document_importer", self.target)self.assertEqual(Document.objects.count(), 4)- def test_filename_prefix(self):+ def test_folder_prefix(self):"""GIVEN:- Request to export documents to directoryWHEN:- - Option use_filename_prefix is used+ - Option use_folder_prefix is usedTHEN:- Documents can be imported again"""@@ -638,7 +638,7 @@ class TestExportImport(DirectoriesMixin, TestCase):os.path.join(self.dirs.media_dir, "documents"),)- manifest = self._do_export(use_filename_prefix=True)+ manifest = self._do_export(use_folder_prefix=True)with paperless_environment() as dirs:self.assertEqual(Document.objects.count(), 4)