Skip to content

Commit 7ab1e16

Browse files
committed
Enforce metadata update
1 parent 226459c commit 7ab1e16

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)
@@ -369,7 +373,10 @@ async def _update_metadata(
369373
try:
370374
if _tab_extension(dv_path) in file_mapping:
371375
file_id = file_mapping[_tab_extension(dv_path)]
372-
elif file.file_name and _is_zip(file.file_name) and not file._is_inside_zip:
376+
elif (
377+
file.file_name and _is_zip(file.file_name)
378+
and not file._is_inside_zip and not file._enforce_metadata_update
379+
):
373380
# When the file is a zip package it will be unpacked and thus
374381
# the expected file name of the zip will not be in the
375382
# dataset, since it has been unpacked.

0 commit comments

Comments
 (0)