From 1a7b551c44c923f2185b08a94edafc116d0346b7 Mon Sep 17 00:00:00 2001 From: Noah Pavlawk Date: Sun, 8 Dec 2024 02:55:28 -0500 Subject: [PATCH] Fix image renaming collisions by appending UUID in mangle_image_name --- cvat/apps/dataset_manager/bindings.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cvat/apps/dataset_manager/bindings.py b/cvat/apps/dataset_manager/bindings.py index 3b2ccd782a88..376a45198ae8 100644 --- a/cvat/apps/dataset_manager/bindings.py +++ b/cvat/apps/dataset_manager/bindings.py @@ -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 @@ -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])