Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix image renaming collisions by appending UUID in mangle_image_name #8791

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion cvat/apps/dataset_manager/bindings.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import os.path as osp
import re
import sys
import uuid
from collections import OrderedDict, defaultdict
from collections.abc import Iterable, Iterator, Mapping, Sequence
from functools import reduce
Expand Down Expand Up @@ -1897,8 +1898,9 @@ def mangle_image_name(name: str, subset: str, names: defaultdict[tuple[str, str]
return osp.extsep.join([image_name, ext])
else:
i = 1
uid = uuid.uuid4().hex
while i < sys.maxsize:
new_image_name = f"{image_name}_{i}"
new_image_name = f"{image_name}_{uid}"
if not names[(subset, new_image_name)]:
names[(subset, name)] += 1
return osp.extsep.join([new_image_name, ext])
Expand Down