From 09a740000810e7ace310fd131a39ebc89c8b2ba2 Mon Sep 17 00:00:00 2001
From: herman dyrkorn <herman.dyrkorn@gmail.com>
Date: Thu, 10 Jun 2021 12:17:53 +0200
Subject: [PATCH] fix bug for rematching salamanders

---
 api/endpoints/editsalamander.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/api/endpoints/editsalamander.py b/api/endpoints/editsalamander.py
index 563b9d5..50adb7f 100644
--- a/api/endpoints/editsalamander.py
+++ b/api/endpoints/editsalamander.py
@@ -218,7 +218,7 @@ def handle_remaining_images(salamander, salamander_path: str, image_id: int, las
         os.rmdir(salamander_path)
         db.session.delete(salamander)
         db.session.commit()
-        if match_bool:
+        if match_bool and result > -1:
             return jsonify({"id": result, "matching": "Match!", "message": "Matched with salamander", 'status': 200})
         else:
             return jsonify(
@@ -236,7 +236,7 @@ def handle_remaining_images(salamander, salamander_path: str, image_id: int, las
             db.session.commit()
             os.rename(processed_path, os.path.join(salamander_path, str(image_id) + "_str" + processed_extension))
             os.rename(original_path, os.path.join(salamander_path, str(image_id) + original_extension))
-        if match_bool:
+        if match_bool and result > -1:
             return jsonify({"id": result, "matching": "Match!", "message": "Matched with salamander", 'status': 200})
         else:
             return jsonify(
-- 
GitLab