Files
J621/backend/apps/library/apps.py
T
JakeBreath 1c2cb8d468 Add an ephemeral similarity check page
- /similar (nav: Similar): drop a file to get the exact MD5 match, the
  perceptual matches against the library, and e621 IQDB candidates
  (auto-run for images when credentials are configured). Read-only —
  nothing enters the library.
- SimilarityCheck model + /api/similarity/ (create/list/retrieve/delete)
  with signed preview URLs and an expires_at timestamp.
- Temp files are wiped on startup (AppConfig.ready, file-only so no
  database access during initialization), lazily past
  SIMILARITY_TTL_MINUTES (default 30, env-overridable), on delete, and
  by manage.py cleanup_similarity.
- uploadFile() takes a target path; .env.example documents the TTL.
2026-09-17 18:22:11 -05:00

22 lines
565 B
Python

import logging
from django.apps import AppConfig
logger = logging.getLogger(__name__)
class LibraryConfig(AppConfig):
name = "apps.library"
def ready(self):
"""Ephemeral similarity-check files never survive a restart."""
from . import similarity
try:
deleted = similarity.purge_similarity_files()
except OSError as exc:
logger.warning("Similarity file purge skipped: %s", exc)
else:
if deleted:
logger.info("Purged %s similarity file(s) on startup", deleted)