From db70943bf0b915e734f6552fd3871a37bc68e7ab Mon Sep 17 00:00:00 2001 From: Mateusz779 Date: Wed, 19 Apr 2023 15:38:24 +0200 Subject: [PATCH] poprawienie buga usuwania zajetego obrazu --- app.py | 2 ++ db.py | 12 +++--------- templates/create.html | 2 +- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/app.py b/app.py index 911cb6c..53529b5 100644 --- a/app.py +++ b/app.py @@ -133,6 +133,8 @@ def delete(image_id): if db.get_user_bytoken(auth_token) is None: return redirect("/login") + if db.get_image_allocation_all_id() is not None: + return jsonify(message="409") filename = db.get_conf_image_id(image_id) squashfs = os.path.join(app.config['UPLOAD_FOLDER'], filename) pubkey = os.path.join(app.config['UPLOAD_FOLDER'], filename.split(".")[0]) diff --git a/db.py b/db.py index 3d732e8..0e067fb 100644 --- a/db.py +++ b/db.py @@ -225,14 +225,8 @@ def get_image_allocation_all(): except: return None -def get_image_allocation(sql, value): - connect() - with get_cur() as cur: - cur.execute(sql, (value,)) - try: - return cur.fetchone()[0] - except: - return None +def get_image_allocation(image_id): + return get_one("SELECT id FROM image_allocation WHERE image_id = %s", image_id) def get_image_allocation_time(token): @@ -243,7 +237,7 @@ def get_image_allocation_time(token): def get_image_allocation_time_id(id): - get_one("SELECT last_access_time FROM image_allocation WHERE id = %s", id) + return get_one("SELECT last_access_time FROM image_allocation WHERE id = %s", id) def get_image_allocation_clientip(token): diff --git a/templates/create.html b/templates/create.html index b46a65d..e8c263d 100644 --- a/templates/create.html +++ b/templates/create.html @@ -75,7 +75,7 @@ form textarea {



-

+