Commit 29919a2b authored by Martin Urban's avatar Martin Urban
Browse files

File: change file name collision behaviour, fix #2123

parent 05afb6f5
......@@ -510,24 +510,24 @@ class FileSystem(object):
# has the name already a counter at its end?
hasCounter = False
preprename = None
counter = prename.split("_")[-1]
counter = prename.split("_copy")[-1]
if counter != prename:
try:
counter = int(counter)
hasCounter = True
preprename = "_".join(prename.split("_")[:-1])
preprename = "_copy".join(prename.split("_copy")[:-1])
except:
pass
if hasCounter:
# increment and try again
counter += 1
newname = "%s_%d%s" % (preprename,
newname = "%s_copy%d%s" % (preprename,
counter,
"" if extension == "" else "." + extension)
else:
newname = "%s_1%s" % (
newname = "%s_copy1%s" % (
prename, "" if extension == "" else "." + extension)
# return
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment