From 6647b32ac06f011f9f3e5ccd924e127ae2ad7612 Mon Sep 17 00:00:00 2001 From: shamoon <4887959+shamoon@users.noreply.github.com> Date: Fri, 16 May 2025 17:30:34 -0700 Subject: [PATCH] Fix: ignore logo file from sanity checker (#9946) --- src/documents/sanity_checker.py | 5 +++++ src/documents/tests/test_sanity_check.py | 12 ++++++++++++ 2 files changed, 17 insertions(+) diff --git a/src/documents/sanity_checker.py b/src/documents/sanity_checker.py index 6cef98f1a..4f7abde06 100644 --- a/src/documents/sanity_checker.py +++ b/src/documents/sanity_checker.py @@ -82,6 +82,11 @@ def check_sanity(*, progress=False, scheduled=True) -> SanityCheckMessages: if lockfile in present_files: present_files.remove(lockfile) + if settings.APP_LOGO: + logo_file = Path(settings.MEDIA_ROOT / settings.APP_LOGO).resolve() + if logo_file in present_files: + present_files.remove(logo_file) + for doc in tqdm(Document.global_objects.all(), disable=not progress): # Check sanity of the thumbnail thumbnail_path: Final[Path] = Path(doc.thumbnail_path).resolve() diff --git a/src/documents/tests/test_sanity_check.py b/src/documents/tests/test_sanity_check.py index 0dec2d53b..c33062c42 100644 --- a/src/documents/tests/test_sanity_check.py +++ b/src/documents/tests/test_sanity_check.py @@ -5,6 +5,7 @@ from pathlib import Path import filelock from django.conf import settings from django.test import TestCase +from django.test import override_settings from documents.models import Document from documents.sanity_checker import check_sanity @@ -157,6 +158,17 @@ class TestSanityCheck(DirectoriesMixin, TestCase): "Orphaned file in media dir", ) + @override_settings( + APP_LOGO="logo/logo.png", + ) + def test_ignore_logo(self): + self.make_test_data() + logo_dir = Path(self.dirs.media_dir, "logo") + logo_dir.mkdir(parents=True, exist_ok=True) + Path(self.dirs.media_dir, "logo", "logo.png").touch() + messages = check_sanity() + self.assertFalse(messages.has_warning) + def test_archive_filename_no_checksum(self): doc = self.make_test_data() doc.archive_checksum = None