]> git.ipfire.org Git - thirdparty/paperless-ngx.git/commitdiff
use pathlib glob
authorMatthieu Helleboid <mhelleboid@hotmail.com>
Fri, 20 Jan 2023 19:51:03 +0000 (20:51 +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_importer.py

index 873a5841d574e394ebd13f6f6258e6cf6a611b31..eeae68e65268ad4bae2f27c53a5a4a733159127a 100644 (file)
@@ -83,13 +83,10 @@ class Command(BaseCommand):
             self.manifest = json.load(f)
         manifest_paths.append(main_manifest_path)
 
-        for root, dirs, files in os.walk(self.source):
-            for file in files:
-                if file.endswith("-manifest.json"):
-                    doc_manifest_path = os.path.normpath(os.path.join(root, file))
-                    with open(doc_manifest_path) as f:
-                        self.manifest += json.load(f)
-                    manifest_paths.append(doc_manifest_path)
+        for file in Path(self.source).glob("**/*-manifest.json"):
+            with open(file) as f:
+                self.manifest += json.load(f)
+            manifest_paths.append(file)
 
         version_path = os.path.normpath(os.path.join(self.source, "version.json"))
         if os.path.exists(version_path):