mirror of
				https://github.com/paperless-ngx/paperless-ngx.git
				synced 2025-10-30 18:22:40 -04:00 
			
		
		
		
	replace --use-filename-prefix with --use-folder-prefix
This commit is contained in:
		
							parent
							
								
									72bacc016a
								
							
						
					
					
						commit
						02a40055f5
					
				| @ -235,7 +235,7 @@ optional arguments: | |||||||
| -f, --use-filename-format | -f, --use-filename-format | ||||||
| -na, --no-archive | -na, --no-archive | ||||||
| -nt, --no-thumbnail | -nt, --no-thumbnail | ||||||
| -p, --use-filename-prefix | -p, --use-folder-prefix | ||||||
| -sm, --split-manifest | -sm, --split-manifest | ||||||
| -z  --zip | -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 in |     can change (new archiver algorithm) and may then cause additional used space in | ||||||
|     a deduplicated backup. |     a 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 exported | ||||||
| in dedicated folders according to their nature: `archive`, `originals`, | in dedicated folders according to their nature: `archive`, `originals`, | ||||||
| `thumbnails` or `json` | `thumbnails` or `json` | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -100,7 +100,7 @@ class Command(BaseCommand): | |||||||
| 
 | 
 | ||||||
|         parser.add_argument( |         parser.add_argument( | ||||||
|             "-p", |             "-p", | ||||||
|             "--use-filename-prefix", |             "--use-folder-prefix", | ||||||
|             default=False, |             default=False, | ||||||
|             action="store_true", |             action="store_true", | ||||||
|             help="Export files in dedicated folders according to their nature: " |             help="Export files in dedicated folders according to their nature: " | ||||||
| @ -138,7 +138,7 @@ class Command(BaseCommand): | |||||||
|         self.exported_files: List[Path] = [] |         self.exported_files: List[Path] = [] | ||||||
|         self.compare_checksums = False |         self.compare_checksums = False | ||||||
|         self.use_filename_format = False |         self.use_filename_format = False | ||||||
|         self.use_filename_prefix = False |         self.use_folder_prefix = False | ||||||
|         self.delete = False |         self.delete = False | ||||||
|         self.no_archive = False |         self.no_archive = False | ||||||
|         self.no_thumbnail = False |         self.no_thumbnail = False | ||||||
| @ -149,7 +149,7 @@ class Command(BaseCommand): | |||||||
|         self.split_manifest = options["split_manifest"] |         self.split_manifest = options["split_manifest"] | ||||||
|         self.compare_checksums = options["compare_checksums"] |         self.compare_checksums = options["compare_checksums"] | ||||||
|         self.use_filename_format = options["use_filename_format"] |         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.delete = options["delete"] | ||||||
|         self.no_archive = options["no_archive"] |         self.no_archive = options["no_archive"] | ||||||
|         self.no_thumbnail = options["no_thumbnail"] |         self.no_thumbnail = options["no_thumbnail"] | ||||||
| @ -287,14 +287,14 @@ class Command(BaseCommand): | |||||||
| 
 | 
 | ||||||
|             # 3.3. write filenames into manifest |             # 3.3. write filenames into manifest | ||||||
|             original_name = base_name |             original_name = base_name | ||||||
|             if self.use_filename_prefix: |             if self.use_folder_prefix: | ||||||
|                 original_name = os.path.join("originals", original_name) |                 original_name = os.path.join("originals", original_name) | ||||||
|             original_target = (self.target / Path(original_name)).resolve() |             original_target = (self.target / Path(original_name)).resolve() | ||||||
|             document_dict[EXPORTER_FILE_NAME] = original_name |             document_dict[EXPORTER_FILE_NAME] = original_name | ||||||
| 
 | 
 | ||||||
|             if not self.no_thumbnail: |             if not self.no_thumbnail: | ||||||
|                 thumbnail_name = base_name + "-thumbnail.webp" |                 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_name = os.path.join("thumbnails", thumbnail_name) | ||||||
|                 thumbnail_target = (self.target / Path(thumbnail_name)).resolve() |                 thumbnail_target = (self.target / Path(thumbnail_name)).resolve() | ||||||
|                 document_dict[EXPORTER_THUMBNAIL_NAME] = thumbnail_name |                 document_dict[EXPORTER_THUMBNAIL_NAME] = thumbnail_name | ||||||
| @ -303,7 +303,7 @@ class Command(BaseCommand): | |||||||
| 
 | 
 | ||||||
|             if not self.no_archive and document.has_archive_version: |             if not self.no_archive and document.has_archive_version: | ||||||
|                 archive_name = base_name + "-archive.pdf" |                 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_name = os.path.join("archive", archive_name) | ||||||
|                 archive_target = (self.target / Path(archive_name)).resolve() |                 archive_target = (self.target / Path(archive_name)).resolve() | ||||||
|                 document_dict[EXPORTER_ARCHIVE_NAME] = archive_name |                 document_dict[EXPORTER_ARCHIVE_NAME] = archive_name | ||||||
| @ -349,7 +349,7 @@ class Command(BaseCommand): | |||||||
| 
 | 
 | ||||||
|             if self.split_manifest: |             if self.split_manifest: | ||||||
|                 manifest_name = base_name + "-manifest.json" |                 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 = os.path.join("json", manifest_name) | ||||||
|                 manifest_name = (self.target / Path(manifest_name)).resolve() |                 manifest_name = (self.target / Path(manifest_name)).resolve() | ||||||
|                 manifest_name.parent.mkdir(parents=True, exist_ok=True) |                 manifest_name.parent.mkdir(parents=True, exist_ok=True) | ||||||
|  | |||||||
| @ -105,7 +105,7 @@ class TestExportImport(DirectoriesMixin, TestCase): | |||||||
|         no_archive=False, |         no_archive=False, | ||||||
|         no_thumbnail=False, |         no_thumbnail=False, | ||||||
|         split_manifest=False, |         split_manifest=False, | ||||||
|         use_filename_prefix=False, |         use_folder_prefix=False, | ||||||
|     ): |     ): | ||||||
|         args = ["document_exporter", self.target] |         args = ["document_exporter", self.target] | ||||||
|         if use_filename_format: |         if use_filename_format: | ||||||
| @ -120,8 +120,8 @@ class TestExportImport(DirectoriesMixin, TestCase): | |||||||
|             args += ["--no-thumbnail"] |             args += ["--no-thumbnail"] | ||||||
|         if split_manifest: |         if split_manifest: | ||||||
|             args += ["--split-manifest"] |             args += ["--split-manifest"] | ||||||
|         if use_filename_prefix: |         if use_folder_prefix: | ||||||
|             args += ["--use-filename-prefix"] |             args += ["--use-folder-prefix"] | ||||||
| 
 | 
 | ||||||
|         call_command(*args) |         call_command(*args) | ||||||
| 
 | 
 | ||||||
| @ -623,12 +623,12 @@ class TestExportImport(DirectoriesMixin, TestCase): | |||||||
|             call_command("document_importer", self.target) |             call_command("document_importer", self.target) | ||||||
|             self.assertEqual(Document.objects.count(), 4) |             self.assertEqual(Document.objects.count(), 4) | ||||||
| 
 | 
 | ||||||
|     def test_filename_prefix(self): |     def test_folder_prefix(self): | ||||||
|         """ |         """ | ||||||
|         GIVEN: |         GIVEN: | ||||||
|             - Request to export documents to directory |             - Request to export documents to directory | ||||||
|         WHEN: |         WHEN: | ||||||
|             - Option use_filename_prefix is used |             - Option use_folder_prefix is used | ||||||
|         THEN: |         THEN: | ||||||
|             - Documents can be imported again |             - Documents can be imported again | ||||||
|         """ |         """ | ||||||
| @ -638,7 +638,7 @@ class TestExportImport(DirectoriesMixin, TestCase): | |||||||
|             os.path.join(self.dirs.media_dir, "documents"), |             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: |         with paperless_environment() as dirs: | ||||||
|             self.assertEqual(Document.objects.count(), 4) |             self.assertEqual(Document.objects.count(), 4) | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user