A community-supported supercharged document management system: scan, index and archive all your documents
Python aiangulararchivingdjangodmsdocument-managementdocument-management-systemllmmachine-learningocroptical-character-recognitionpdf
Corrects the logic of thumbnail path to account for both getting existing path or building expected path
Trenton Holmes153d0bb12a75
diff --git a/src/documents/models.py b/src/documents/models.pyindex bd69aaff1..d889ef2c5 100644--- a/src/documents/models.py+++ b/src/documents/models.py@@ -300,10 +300,26 @@ class Document(models.Model):png_file_name += ".gpg"webp_file_name += ".gpg"- thumb = os.path.join(settings.THUMBNAIL_DIR, webp_file_name)-- if not os.path.exists(thumb):- thumb = os.path.join(settings.THUMBNAIL_DIR, png_file_name)+ # This property is used to both generate the file path+ # and locate the file itself+ # Hence why this looks a little weird++ webp_file_path = os.path.join(settings.THUMBNAIL_DIR, webp_file_name)+ png_file_path = thumb = os.path.join(settings.THUMBNAIL_DIR, png_file_name)++ # 1. Assume the thumbnail is WebP++ if not os.path.exists(webp_file_path):+ # 2. If WebP doesn't exist, check PNG+ if not os.path.exists(png_file_path):+ # 3. If PNG doesn't exist, filename is being constructed, return WebP+ thumb = webp_file_path+ else:+ # 2.1 - PNG file exists, return path to it+ thumb = png_file_name+ else:+ # 1.1 - WebP file exists, return path to it+ thumb = webp_file_pathreturn thumb@property