From 712a43e6e8edb83ce1593f6dd2fdea704cb0ea1b Mon Sep 17 00:00:00 2001 From: quimmrc Date: Mon, 16 Dec 2024 12:47:30 +0100 Subject: [PATCH] enable upload of diff. sounds with same filename --- accounts/views.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/accounts/views.py b/accounts/views.py index f4976519d..8b6a15bd7 100644 --- a/accounts/views.py +++ b/accounts/views.py @@ -1284,7 +1284,18 @@ def upload(request, no_flash=False): form = UploadFileForm(request.POST, request.FILES) if form.is_valid(): submitted_files = request.FILES.getlist('files') + files_names = list() for file_ in submitted_files: + #check for duplicated names and add an identifier, otherwise, different files with the same + #name will be overwritten in the description queue + if file_.name in files_names: + name_counter = files_names.count(file_.name) + files_names.append(file_.name) + name, extension = os.path.splitext(file_.name) + file_.name = "%s(%d)%s" % (name, name_counter, extension) + else: + files_names.append(file_.name) + if handle_uploaded_file(request.user.id, file_): uploaded_file = file_ successes += 1