Skip to content

Commit 421d5f7

Browse files
committed
Enforce metadata update
1 parent 509ae92 commit 421d5f7

2 files changed

Lines changed: 10 additions & 1 deletion

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+
_enforce_metadata_update (bool): Indicates if metadata update is enforced.
3334
_is_inside_zip (bool): Indicates if the file is packaged inside a zip archive.
3435
3536
Methods:
@@ -60,6 +61,7 @@ class File(BaseModel):
6061

6162
_size: int = PrivateAttr(default=0)
6263
_unchanged_data: bool = PrivateAttr(default=False)
64+
_enforce_metadata_update: bool = PrivateAttr(default=False)
6365
_is_inside_zip: bool = PrivateAttr(default=False)
6466

6567
def extract_file_name(self):

dvuploader/nativeupload.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,10 @@ async def native_upload(
9595
files_new_metadata = [file for file in files if file.to_replace and file._unchanged_data]
9696
files_replace = [file for file in files if file.to_replace and not file._unchanged_data]
9797

98+
# These are not in a package but need a metadtata update, ensure even for zips
99+
for file in files_new_metadata:
100+
file._enforce_metadata_update = True
101+
98102
async with httpx.AsyncClient(**session_params) as session:
99103
with tempfile.TemporaryDirectory() as tmp_dir:
100104
packages = distribute_files(files_new)
@@ -364,7 +368,10 @@ async def _update_metadata(
364368
try:
365369
if _tab_extension(dv_path) in file_mapping:
366370
file_id = file_mapping[_tab_extension(dv_path)]
367-
elif file.file_name and _is_zip(file.file_name) and not file._is_inside_zip:
371+
elif (
372+
file.file_name and _is_zip(file.file_name)
373+
and not file._is_inside_zip and not file._enforce_metadata_update
374+
):
368375
# When the file is a zip package it will be unpacked and thus
369376
# the expected file name of the zip will not be in the
370377
# dataset, since it has been unpacked.

0 commit comments

Comments
 (0)