From 891ddbc45956d6c904984a39c318b384db61bdcd Mon Sep 17 00:00:00 2001 From: Topvennie Date: Thu, 23 May 2024 23:33:47 +0200 Subject: [PATCH] fix: zip structure --- backend/api/fixtures/realistic/realistic.yaml | 6 +++--- backend/api/logic/parse_zip_files.py | 2 +- backend/api/tasks/structure_check.py | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/backend/api/fixtures/realistic/realistic.yaml b/backend/api/fixtures/realistic/realistic.yaml index f7664d29..3224250e 100644 --- a/backend/api/fixtures/realistic/realistic.yaml +++ b/backend/api/fixtures/realistic/realistic.yaml @@ -139,7 +139,7 @@ - model: api.structurecheck pk: 1 fields: - path: "verslag/" + path: "verslag" project: 0 obligated_extensions: - 3 @@ -147,7 +147,7 @@ - model: api.structurecheck pk: 2 fields: - path: src/ + path: src project: 1 obligated_extensions: - 1 @@ -156,7 +156,7 @@ - model: api.structurecheck pk: 3 fields: - path: verslag/ + path: verslag project: 1 obligated_extensions: - 3 diff --git a/backend/api/logic/parse_zip_files.py b/backend/api/logic/parse_zip_files.py index cc21f531..e1f3ee8e 100644 --- a/backend/api/logic/parse_zip_files.py +++ b/backend/api/logic/parse_zip_files.py @@ -24,7 +24,7 @@ def parse_zip(project: Project, zip_file: InMemoryUploadedFile) -> bool: if common_prefix[-1] != '/': prefixes = prefixes[:-1] - directories += [prefix + '/' for prefix in prefixes] + directories += [prefix for prefix in prefixes] # Add for each directory a structure check for directory in directories: diff --git a/backend/api/tasks/structure_check.py b/backend/api/tasks/structure_check.py index d22cd866..8d7cdaac 100644 --- a/backend/api/tasks/structure_check.py +++ b/backend/api/tasks/structure_check.py @@ -89,4 +89,4 @@ def _get_all_name_ext(path: str) -> dict[str, str]: with zipfile.ZipFile(zip_data, 'r') as inner_zip: file_list = inner_zip.namelist() - return {file: file.split('.')[-1] for file in file_list} + return {'/'.join(file.split('/')[:-1]): file.split('.')[-1] for file in file_list}