From 5e8250a0447b477431f745b5deea787204402b26 Mon Sep 17 00:00:00 2001 From: Lukas Barragan Torres Date: Thu, 23 May 2024 16:43:53 +0200 Subject: [PATCH] fix: file constraint now checks file is not a directory --- .../simple_submission_checks/constraints/file_constraint.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/backend/domain/simple_submission_checks/constraints/file_constraint.py b/backend/domain/simple_submission_checks/constraints/file_constraint.py index a88dde0c..457eaf13 100644 --- a/backend/domain/simple_submission_checks/constraints/file_constraint.py +++ b/backend/domain/simple_submission_checks/constraints/file_constraint.py @@ -1,4 +1,3 @@ -import os from pathlib import Path from pydantic import BaseModel @@ -11,9 +10,9 @@ class FileConstraint(BaseModel): file_name: str def validate_constraint(self, path: Path) -> FileConstraintResult: - directory = os.listdir(path) + file_path = path / self.file_name - if self.file_name not in directory: + if not file_path.exists() or file_path.is_dir(): return FileConstraintResult( file_name=self.file_name, is_ok=False,