mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2026-04-13 11:38:52 +00:00
Compare commits
2 Commits
dev
...
fix/sanity
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
377f3bc0ea | ||
|
|
9e2e8a2be0 |
@@ -182,8 +182,9 @@ def _check_thumbnail(
|
|||||||
present_files: set[Path],
|
present_files: set[Path],
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Verify the thumbnail exists and is readable."""
|
"""Verify the thumbnail exists and is readable."""
|
||||||
thumbnail_path: Final[Path] = Path(doc.thumbnail_path).resolve()
|
# doc.thumbnail_path already returns a resolved Path; no need to re-resolve.
|
||||||
if not thumbnail_path.exists() or not thumbnail_path.is_file():
|
thumbnail_path: Final[Path] = doc.thumbnail_path
|
||||||
|
if not thumbnail_path.is_file():
|
||||||
messages.error(doc.pk, "Thumbnail of document does not exist.")
|
messages.error(doc.pk, "Thumbnail of document does not exist.")
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -200,8 +201,9 @@ def _check_original(
|
|||||||
present_files: set[Path],
|
present_files: set[Path],
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Verify the original file exists, is readable, and has matching checksum."""
|
"""Verify the original file exists, is readable, and has matching checksum."""
|
||||||
source_path: Final[Path] = Path(doc.source_path).resolve()
|
# doc.source_path already returns a resolved Path; no need to re-resolve.
|
||||||
if not source_path.exists() or not source_path.is_file():
|
source_path: Final[Path] = doc.source_path
|
||||||
|
if not source_path.is_file():
|
||||||
messages.error(doc.pk, "Original of document does not exist.")
|
messages.error(doc.pk, "Original of document does not exist.")
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -237,8 +239,9 @@ def _check_archive(
|
|||||||
elif doc.has_archive_version:
|
elif doc.has_archive_version:
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
assert isinstance(doc.archive_path, Path)
|
assert isinstance(doc.archive_path, Path)
|
||||||
archive_path: Final[Path] = Path(doc.archive_path).resolve()
|
# doc.archive_path already returns a resolved Path; no need to re-resolve.
|
||||||
if not archive_path.exists() or not archive_path.is_file():
|
archive_path: Final[Path] = doc.archive_path # type: ignore[assignment]
|
||||||
|
if not archive_path.is_file():
|
||||||
messages.error(doc.pk, "Archived version of document does not exist.")
|
messages.error(doc.pk, "Archived version of document does not exist.")
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -314,7 +317,15 @@ def check_sanity(
|
|||||||
messages = SanityCheckMessages()
|
messages = SanityCheckMessages()
|
||||||
present_files = _build_present_files()
|
present_files = _build_present_files()
|
||||||
|
|
||||||
documents = Document.global_objects.all()
|
documents = Document.global_objects.only(
|
||||||
|
"pk",
|
||||||
|
"filename",
|
||||||
|
"mime_type",
|
||||||
|
"checksum",
|
||||||
|
"archive_checksum",
|
||||||
|
"archive_filename",
|
||||||
|
"content",
|
||||||
|
).iterator(chunk_size=500)
|
||||||
for doc in iter_wrapper(documents):
|
for doc in iter_wrapper(documents):
|
||||||
_check_document(doc, messages, present_files)
|
_check_document(doc, messages, present_files)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user