A community-supported supercharged document management system: scan, index and archive all your documents
Python aiangulararchivingdjangodmsdocument-managementdocument-management-systemllmmachine-learningocroptical-character-recognitionpdf
Fix: Clear metadata cache when the filename(s) change (#5957)
Trenton Hc57c1d5389fd
diff --git a/src/documents/caching.py b/src/documents/caching.pyindex d80f319f7..a1f20d086 100644--- a/src/documents/caching.py+++ b/src/documents/caching.py@@ -189,6 +189,11 @@ def refresh_metadata_cache(cache.touch(doc_key, timeout)+def clear_metadata_cache(document_id: int) -> None:+ doc_key = get_metadata_cache_key(document_id)+ cache.delete(doc_key)++def get_thumbnail_modified_key(document_id: int) -> str:"""Builds the key to store a thumbnail's timestampdiff --git a/src/documents/signals/handlers.py b/src/documents/signals/handlers.pyindex b8067df86..b6903d98c 100644--- a/src/documents/signals/handlers.py+++ b/src/documents/signals/handlers.py@@ -22,6 +22,7 @@ from django.utils import timezonefrom filelock import FileLockfrom documents import matching+from documents.caching import clear_metadata_cachefrom documents.classifier import DocumentClassifierfrom documents.consumer import parse_doc_title_w_placeholdersfrom documents.file_handling import create_source_path_directory@@ -434,7 +435,9 @@ def update_filename_and_move_files(sender, instance: Document, **kwargs):Document.objects.filter(pk=instance.pk).update(filename=instance.filename,archive_filename=instance.archive_filename,+ modified=timezone.now(),)+ clear_metadata_cache(instance.pk)except (OSError, DatabaseError, CannotMoveFilesException) as e:logger.warning(f"Exception during file handling: {e}")