From 2454828ec38d28e1b15e93f71196cf5f4201d881 Mon Sep 17 00:00:00 2001 From: ElementalAlchemist Date: Thu, 7 Nov 2024 00:03:15 -0600 Subject: [PATCH] Fix name duplicate check to only run when the template name is changed Without checking first, a rename is required for all thumbnail template modifications. --- thrimshim/thrimshim/main.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/thrimshim/thrimshim/main.py b/thrimshim/thrimshim/main.py index a90dd02..99c1190 100644 --- a/thrimshim/thrimshim/main.py +++ b/thrimshim/thrimshim/main.py @@ -724,12 +724,13 @@ def update_template(name, artist=None): if results.fetchone() is None: return 'Template with name {} does not exist'.format(name), 400 # check if new name is in database - query = sql.SQL(""" - SELECT name FROM templates WHERE name = %s - """) - results = database.query(conn, query, new_template['name']) - if results.fetchone() is not None: - return 'Template with name {} already exists'.format(new_template['name']), 400 + if name != new_template["name"]: + query = sql.SQL(""" + SELECT name FROM templates WHERE name = %s + """) + results = database.query(conn, query, new_template['name']) + if results.fetchone() is not None: + return 'Template with name {} already exists'.format(new_template['name']), 400 query = sql.SQL(""" UPDATE templates