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
+6 -1
View File
@@ -2,7 +2,7 @@
import os
import shutil
from core.constants import TRASH_FILES
from core.constants import TRASH_FILES, IMAGE_EXTENSIONS, FOREIGN_ALLOWED
from core.result import StepResult
@@ -19,6 +19,11 @@ def clean_directory(work_dir: str) -> StepResult:
full = os.path.join(root, f)
os.remove(full)
removed.append(os.path.relpath(full, work_dir))
elif os.path.splitext(f)[1].lower() not in IMAGE_EXTENSIONS \
and f.lower() not in FOREIGN_ALLOWED:
full = os.path.join(root, f)
os.remove(full)
removed.append(os.path.relpath(full, work_dir))
for d in dirs:
if d.lower() in TRASH_FILES:
full = os.path.join(root, d)