From 359dcb63e3b16a777de47090d21bee2ae448511d Mon Sep 17 00:00:00 2001 From: dgtlmoon Date: Thu, 10 Nov 2022 20:01:07 +0100 Subject: [PATCH] Stability fix related to the new watch check count (#1113) --- changedetectionio/update_worker.py | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/changedetectionio/update_worker.py b/changedetectionio/update_worker.py index 17d13e97..564be402 100644 --- a/changedetectionio/update_worker.py +++ b/changedetectionio/update_worker.py @@ -282,18 +282,19 @@ class update_worker(threading.Thread): self.app.logger.error("Exception reached processing watch UUID: %s - %s", uuid, str(e)) self.datastore.update_watch(uuid=uuid, update_obj={'last_error': str(e)}) - # Always record that we atleast tried - count = self.datastore.data['watching'][uuid].get('check_count', 0) + 1 - self.datastore.update_watch(uuid=uuid, update_obj={'fetch_time': round(time.time() - now, 3), - 'last_checked': round(time.time()), - 'check_count': count - }) - - # Always save the screenshot if it's available - if update_handler.screenshot: - self.datastore.save_screenshot(watch_uuid=uuid, screenshot=update_handler.screenshot) - if update_handler.xpath_data: - self.datastore.save_xpath_data(watch_uuid=uuid, data=update_handler.xpath_data) + if self.datastore.data['watching'].get(uuid): + # Always record that we atleast tried + count = self.datastore.data['watching'][uuid].get('check_count', 0) + 1 + self.datastore.update_watch(uuid=uuid, update_obj={'fetch_time': round(time.time() - now, 3), + 'last_checked': round(time.time()), + 'check_count': count + }) + + # Always save the screenshot if it's available + if update_handler.screenshot: + self.datastore.save_screenshot(watch_uuid=uuid, screenshot=update_handler.screenshot) + if update_handler.xpath_data: + self.datastore.save_xpath_data(watch_uuid=uuid, data=update_handler.xpath_data) self.current_uuid = None # Done