detecció de fitxers extranys en el fitxer

This commit is contained in:
2026-02-20 12:50:03 +01:00
parent eeb9ce6879
commit 448c50b846
5 changed files with 38 additions and 11 deletions
+15 -1
View File
@@ -3,7 +3,7 @@
import os
import re
from core.constants import IMAGE_EXTENSIONS, TRASH_FILES
from core.constants import IMAGE_EXTENSIONS, TRASH_FILES, FOREIGN_ALLOWED
from core.result import StepResult
@@ -104,6 +104,20 @@ def check_image_extensions(names: list[str]) -> StepResult:
return StepResult(step="check_image_extensions", changed=False, warnings=warnings)
def check_foreign(names: list[str]) -> StepResult:
"""Detecta ficheros que no son imágenes ni metadata permitida."""
found = []
for name in names:
basename = name.replace("\\", "/").rstrip("/").rsplit("/", 1)[-1]
if not basename:
continue # entrada de directorio
ext = os.path.splitext(basename)[1].lower()
if ext not in IMAGE_EXTENSIONS and basename.lower() not in FOREIGN_ALLOWED:
found.append(name)
warnings = [f"Fichero extraño: {f}" for f in sorted(found)]
return StepResult(step="check_foreign", changed=False, warnings=warnings)
def check_comicinfo(names: list[str]) -> StepResult:
"""Detecta ausencia de ComicInfo.xml."""
found = any(