mirror of
				https://github.com/paperless-ngx/paperless-ngx.git
				synced 2025-10-30 10:12:35 -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 | ||||
| -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 in | ||||
|     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`, | ||||
| `thumbnails` or `json` | ||||
| 
 | ||||
|  | ||||
| @ -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 = False | ||||
|         self.use_filename_format = False | ||||
|         self.use_filename_prefix = False | ||||
|         self.use_folder_prefix = False | ||||
|         self.delete = False | ||||
|         self.no_archive = False | ||||
|         self.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 manifest | ||||
|             original_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_name | ||||
| 
 | ||||
|             if 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) | ||||
|  | ||||
| @ -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 directory | ||||
|         WHEN: | ||||
|             - Option use_filename_prefix is used | ||||
|             - Option use_folder_prefix is used | ||||
|         THEN: | ||||
|             - 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) | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user