Fix bad parameter in delete call on import dir cleanup

This commit is contained in:
Andrew
2025-11-21 14:02:02 -04:00
parent bece83c9e4
commit c63db67b04

View File

@@ -5,6 +5,7 @@ import threading
import asyncio
import datetime
import json
from pathlib import Path
from zoneinfo import ZoneInfoNotFoundError
from tzlocal import get_localzone
from apscheduler.events import EVENT_JOB_EXECUTED
@@ -815,15 +816,16 @@ class TasksManager:
os.remove(os.path.join(file))
except FileNotFoundError:
logger.debug("Could not clear out file from temp directory")
for file in os.listdir(
os.path.join(self.controller.project_root, "import", "upload")
):
if self.helper.is_file_older_than_x_days(
os.path.join(self.controller.project_root, "import", "upload", file)
):
import_path = Path(self.controller.project_root, "import", "upload")
for file in os.listdir(import_path):
file_path = Path(import_path, file).resolve(strict=True)
if not self.helper.validate_traversal(import_path, file_path):
logger.error(
"Traversal detected while deleting import file %s", file_path
)
if self.helper.is_file_older_than_x_days(Path(import_path, file)):
try:
os.remove(os.path.join(file))
os.remove(Path(import_path, file))
except FileNotFoundError:
logger.debug("Could not clear out file from import directory")