]> git.ipfire.org Git - thirdparty/paperless-ngx.git/commitdiff
fix bug on administration exporter when using -d, --delete option
authorMatthieu Helleboid <mhelleboid@hotmail.com>
Sat, 14 Jan 2023 11:03:25 +0000 (12:03 +0100)
committerTrenton H <797416+stumpylog@users.noreply.github.com>
Tue, 24 Jan 2023 19:06:49 +0000 (11:06 -0800)
src/documents/management/commands/document_exporter.py

index 12828a7a048787c538a0053067194a8b8a287c19..9ce0f5f627019d9ce92a12b968fb35ede0107092 100644 (file)
@@ -350,6 +350,8 @@ class Command(BaseCommand):
                 if self.use_filename_prefix:
                     manifest_name = os.path.join("json", manifest_name)
                 manifest_name = os.path.join(self.target, manifest_name)
+                if manifest_name in self.files_in_export_dir:
+                    self.files_in_export_dir.remove(manifest_name)
                 os.makedirs(os.path.dirname(manifest_name), exist_ok=True)
                 with open(manifest_name, "w") as f:
                     json.dump([document_manifest[index]], f, indent=2)
@@ -357,19 +359,20 @@ class Command(BaseCommand):
         # 4.1 write manifest to target folder
         manifest_path = (self.target / Path("manifest.json")).resolve()
         manifest_path.write_text(json.dumps(manifest, indent=2))
+        if manifest_path in self.files_in_export_dir:
+            self.files_in_export_dir.remove(manifest_path)
 
         # 4.2 write version information to target folder
         version_path = (self.target / Path("version.json")).resolve()
         version_path.write_text(
             json.dumps({"version": version.__full_version_str__}, indent=2),
         )
+        if version_path in self.files_in_export_dir:
+            self.files_in_export_dir.remove(version_path)
 
         if self.delete:
             # 5. Remove files which we did not explicitly export in this run
 
-            if manifest_path in self.files_in_export_dir:
-                self.files_in_export_dir.remove(manifest_path)
-
             for f in self.files_in_export_dir:
                 f.unlink()