Skip to content

Commit 7d9b9b1

Browse files
author
Ben Greiner
committed
Keep track of files put into zip package and don't skip their metadata even when they are zips
1 parent 8e0e1fb commit 7d9b9b1

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

dvuploader/file.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ class File(BaseModel):
2929
3030
Private Attributes:
3131
_size (int): Size of the file in bytes.
32+
_is_inside_zip (bool): Indicates if the file is packaged inside a zip archive.
3233
3334
Methods:
3435
extract_file_name(): Extracts filename from filepath and initializes file handler.
@@ -57,6 +58,7 @@ class File(BaseModel):
5758
tab_ingest: bool = Field(default=True, alias="tabIngest")
5859

5960
_size: int = PrivateAttr(default=0)
61+
_is_inside_zip: bool = PrivateAttr(default=False)
6062

6163
def extract_file_name(self):
6264
"""

dvuploader/nativeupload.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -345,8 +345,8 @@ async def _update_metadata(
345345
try:
346346
if _tab_extension(dv_path) in file_mapping:
347347
file_id = file_mapping[_tab_extension(dv_path)]
348-
elif file.file_name and _is_zip(file.file_name):
349-
# When the file is a zip it will be unpacked and thus
348+
elif file.file_name and _is_zip(file.file_name) and not file._is_inside_zip:
349+
# When the file is a zip package it will be unpacked and thus
350350
# the expected file name of the zip will not be in the
351351
# dataset, since it has been unpacked.
352352
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)