diff --git a/myriad/manage.py b/myriad/manage.py index 58d4ae9..36f310c 100644 --- a/myriad/manage.py +++ b/myriad/manage.py @@ -774,7 +774,18 @@ def assets(): if "image" in request.files: file = request.files["image"] filename = file.filename - file.save(os.path.join(current_app.config["MISC_UPLOAD_FOLDER"], filename)) + fname, ftype = filename.split(".") + + i = 0 + if os.path.exists(os.path.join(current_app.config["MISC_UPLOAD_FOLDER"], filename)): + i = 2 + while os.path.exists(os.path.join(current_app.config["MISC_UPLOAD_FOLDER"], fname+str(i)+"."+ftype)): + i += 1 + + if i == 0: + file.save(os.path.join(current_app.config["MISC_UPLOAD_FOLDER"], filename)) + else: + file.save(os.path.join(current_app.config["MISC_UPLOAD_FOLDER"], fname+str(i)+"."+ftype)) icons = db.execute("SELECT * FROM icons").fetchall() icon_storage = os.listdir(current_app.config["ICON_UPLOAD_FOLDER"])