Skip to content

Commit 226459c

Browse files
committed
Keep track of files put into zip package and don't skip their metadata even when they are zips
1 parent 5e29307 commit 226459c

3 files changed

Lines changed: 5 additions & 2 deletions

File tree

dvuploader/file.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ class File(BaseModel):
3030
Private Attributes:
3131
_size (int): Size of the file in bytes.
3232
_unchanged_data (bool): Indicates if the file data has not changed since last upload.
33+
_is_inside_zip (bool): Indicates if the file is packaged inside a zip archive.
3334
3435
Methods:
3536
extract_file_name(): Extracts filename from filepath and initializes file handler.
@@ -59,6 +60,7 @@ class File(BaseModel):
5960

6061
_size: int = PrivateAttr(default=0)
6162
_unchanged_data: bool = PrivateAttr(default=False)
63+
_is_inside_zip: bool = PrivateAttr(default=False)
6264

6365
def extract_file_name(self):
6466
"""

dvuploader/nativeupload.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -369,8 +369,8 @@ async def _update_metadata(
369369
try:
370370
if _tab_extension(dv_path) in file_mapping:
371371
file_id = file_mapping[_tab_extension(dv_path)]
372-
elif file.file_name and _is_zip(file.file_name):
373-
# When the file is a zip it will be unpacked and thus
372+
elif file.file_name and _is_zip(file.file_name) and not file._is_inside_zip:
373+
# When the file is a zip package it will be unpacked and thus
374374
# the expected file name of the zip will not be in the
375375
# dataset, since it has been unpacked.
376376
continue

dvuploader/packaging.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ def zip_files(
9898
data=file.handler.read(), # type: ignore
9999
zinfo_or_arcname=_create_arcname(file),
100100
)
101+
file._is_inside_zip = True
101102

102103
return path
103104

0 commit comments

Comments
 (0)