detecció de fitxers extranys en el fitxer
This commit is contained in:
+15
-1
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user