]> git.ipfire.org Git - thirdparty/paperless-ngx.git/commitdiff
Copy default thumbnail if thumbnail generation fails
authorJohannes Plunien <johannes@plunien.com>
Tue, 20 Jun 2023 06:56:27 +0000 (08:56 +0200)
committerTrenton H <797416+stumpylog@users.noreply.github.com>
Tue, 20 Jun 2023 18:28:46 +0000 (11:28 -0700)
Fix #3631

src/documents/parsers.py

index 265219412bccfbe32fac280d9d42b6846cd8a395..e1d7365fbf8478e893328c79d44f7596038add3b 100644 (file)
@@ -202,7 +202,12 @@ def make_thumbnail_from_pdf_gs_fallback(in_path, temp_dir, logging_group=None) -
         return out_path
 
     except ParseError:
-        return get_default_thumbnail()
+        # The caller might expect a generated thumbnail that can be moved,
+        # so we need to copy it before it gets moved.
+        # https://github.com/paperless-ngx/paperless-ngx/issues/3631
+        default_thumbnail_path = os.path.join(temp_dir, "document.png")
+        shutil.copy2(get_default_thumbnail(), default_thumbnail_path)
+        return default_thumbnail_path
 
 
 def make_thumbnail_from_pdf(in_path, temp_dir, logging_group=None) -> str: