From 6550b87134908e1aae2bce58f734d11687325078 Mon Sep 17 00:00:00 2001 From: peery Date: Tue, 22 Jun 2021 17:13:26 +0200 Subject: [PATCH] Made Seeking next/prev Unknown more reliable An additional search over the image hash is now being performed if the path returned no result. --- ArtNet/artnet_manager.py | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/ArtNet/artnet_manager.py b/ArtNet/artnet_manager.py index 59081b2..dc84dc6 100644 --- a/ArtNet/artnet_manager.py +++ b/ArtNet/artnet_manager.py @@ -262,16 +262,20 @@ class ArtNetManager: break image_db_result = self.db_connection.get_art_by_path(self.all_images[curr_searched_image_index]) + if image_db_result is None: image_db_result = self.db_connection.get_art_by_hash( self.get_md5_of_image(self.all_images[curr_searched_image_index]) ) if image_db_result is None: # image is unknown to database - next_unknown = curr_searched_image_index - break - else: - curr_searched_image_index += 1 + image_db_result = self.db_connection.get_art_by_hash( + self.get_md5_of_image(self.all_images[curr_searched_image_index])) + if image_db_result is None: + next_unknown = curr_searched_image_index + break + + curr_searched_image_index += 1 if next_unknown: return curr_searched_image_index @@ -297,10 +301,13 @@ class ArtNetManager: image_db_result = self.db_connection.get_art_by_path(self.all_images[curr_searched_image_index]) if image_db_result is None: # image is unknown to database - next_unknown = curr_searched_image_index - break - else: - curr_searched_image_index -= 1 + image_db_result = self.db_connection.get_art_by_hash( + self.get_md5_of_image(self.all_images[curr_searched_image_index])) + if image_db_result is None: + next_unknown = curr_searched_image_index + break + + curr_searched_image_index -= 1 if next_unknown: return curr_searched_image_index