Skip to content

Commit

Permalink
check for tab conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
JR-1991 committed May 12, 2024
1 parent efc3cdb commit 7723a80
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions dvuploader/nativeupload.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,10 @@ async def _update_metadata(

for file in files:
dv_path = os.path.join(file.directory_label, file.file_name) # type: ignore
has_tab_equivalent = _has_tab_equivalent(file.file_name, file_mapping.keys()) # type: ignore

if has_tab_equivalent and not dv_path.endswith(".tab"):
dv_path = os.path.splitext(dv_path)[0] + ".tab"

try:
file_id = file_mapping[dv_path]
Expand All @@ -287,6 +291,12 @@ async def _update_metadata(
await asyncio.gather(*tasks)


def _has_tab_equivalent(filename: str, filenames: List[str]) -> bool:
"""Returns True if the filename has a tab extension."""
name = os.path.splitext(filename)[0]
return any(f"{name}.tab" == fname for fname in filenames)


@tenacity.retry(
wait=tenacity.wait_fixed(0.3),
stop=tenacity.stop_after_attempt(MAX_RETRIES),
Expand Down

0 comments on commit 7723a80

Please sign in to comment.