poprawienie buga usuwania zajetego obrazu

This commit is contained in:
Mateusz779 2023-04-19 15:38:24 +02:00
parent 9724dbde18
commit db70943bf0
3 changed files with 6 additions and 10 deletions

2
app.py
View File

@ -133,6 +133,8 @@ def delete(image_id):
if db.get_user_bytoken(auth_token) is None: if db.get_user_bytoken(auth_token) is None:
return redirect("/login") 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) filename = db.get_conf_image_id(image_id)
squashfs = os.path.join(app.config['UPLOAD_FOLDER'], filename) squashfs = os.path.join(app.config['UPLOAD_FOLDER'], filename)
pubkey = os.path.join(app.config['UPLOAD_FOLDER'], filename.split(".")[0]) pubkey = os.path.join(app.config['UPLOAD_FOLDER'], filename.split(".")[0])

12
db.py
View File

@ -225,14 +225,8 @@ def get_image_allocation_all():
except: except:
return None return None
def get_image_allocation(sql, value): def get_image_allocation(image_id):
connect() return get_one("SELECT id FROM image_allocation WHERE image_id = %s", image_id)
with get_cur() as cur:
cur.execute(sql, (value,))
try:
return cur.fetchone()[0]
except:
return None
def get_image_allocation_time(token): def get_image_allocation_time(token):
@ -243,7 +237,7 @@ def get_image_allocation_time(token):
def get_image_allocation_time_id(id): 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): def get_image_allocation_clientip(token):

View File

@ -75,7 +75,7 @@ form textarea {
<label>Nazwa tokenu:</label><br> <label>Nazwa tokenu:</label><br>
<input type="text" name="token_name" required><br><br> <input type="text" name="token_name" required><br><br>
<label>Długość klucza:</label><br> <label>Długość klucza:</label><br>
<input type="number" name="key_length" min="1024" required><br><br> <input type="number" name="key_length" min="1024" value="2048" required><br><br>
<label>Adres ip VPN:</label><br> <label>Adres ip VPN:</label><br>
<input type="text" name="ip" required><br><br> <input type="text" name="ip" required><br><br>
<label>Konfiguracja authorized_keys:</label><br> <label>Konfiguracja authorized_keys:</label><br>