From 4cb2dc8131f15111024265d58a28f85c4930d843 Mon Sep 17 00:00:00 2001 From: Sanj Date: Wed, 9 Feb 2011 00:15:25 +0530 Subject: [PATCH] fix uploads --- edgware/files/views.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/edgware/files/views.py b/edgware/files/views.py index 7a50899..ad25a4d 100644 --- a/edgware/files/views.py +++ b/edgware/files/views.py @@ -60,7 +60,11 @@ def add_folder(request): category.save() user = request.user # import pdb;pdb.set_trace() - shutil.move(join(FTP_ROOT, folder_name), join(UPLOAD_ROOT, folder_name)) + n = 1 + while os.path.exists(join(UPLOAD_ROOT, folder_name)): + n += 1 + folder_name = u'%s (%s)' % (form.cleaned_data['folder_name'], n) + shutil.move(join(FTP_ROOT, folder_name), UPLOAD_ROOT) File.addFiles(category, user, folder_name) return render_to_response("files/added_folder.html", { 'folder_name': folder_name,