From 491e0fc9c008c893a5a5633f01ca3bc36105d010 Mon Sep 17 00:00:00 2001 From: dgtlmoon Date: Mon, 17 Jun 2024 11:17:43 +0200 Subject: [PATCH] Dont clear when the same, only clear the error on edit --- changedetectionio/flask_app.py | 3 ++- .../tests/test_filter_failure_notification.py | 15 ++++++++------- changedetectionio/update_worker.py | 3 +-- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/changedetectionio/flask_app.py b/changedetectionio/flask_app.py index 690a1511..d5ea2460 100644 --- a/changedetectionio/flask_app.py +++ b/changedetectionio/flask_app.py @@ -680,7 +680,8 @@ def changedetection_app(config=None, datastore_o=None): if request.method == 'POST' and form.validate(): extra_update_obj = { - 'filter_failure_notification_threshold_attempts': 0 + 'consecutive_filter_failures': 0, + 'last_error' : False } if request.args.get('unpause_on_save'): diff --git a/changedetectionio/tests/test_filter_failure_notification.py b/changedetectionio/tests/test_filter_failure_notification.py index 518f07aa..6d4c3154 100644 --- a/changedetectionio/tests/test_filter_failure_notification.py +++ b/changedetectionio/tests/test_filter_failure_notification.py @@ -21,7 +21,10 @@ def set_response_with_filter(): f.write(test_return_data) return None -def run_filter_test(client, content_filter): +def run_filter_test(client, live_server, content_filter): + + # Response WITHOUT the filter ID element + set_original_response() # cleanup for the next client.get( @@ -90,8 +93,8 @@ def run_filter_test(client, content_filter): # Now the notification should not exist, because we didnt reach the threshold assert not os.path.isfile("test-datastore/notification.txt") - # recheck it up to just before the threshold - for i in range(0, App._FILTER_FAILURE_THRESHOLD_ATTEMPTS_DEFAULT-1): + # recheck it up to just before the threshold, including the fact that in the previous POST it would have rechecked (and incremented) + for i in range(0, App._FILTER_FAILURE_THRESHOLD_ATTEMPTS_DEFAULT-2): client.get(url_for("form_watch_checknow"), follow_redirects=True) wait_for_all_checks(client) time.sleep(2) # delay for apprise to fire @@ -149,11 +152,9 @@ def test_setup(live_server): live_server_setup(live_server) def test_check_include_filters_failure_notification(client, live_server): - set_original_response() - run_filter_test(client, '#nope-doesnt-exist') + run_filter_test(client, live_server,'#nope-doesnt-exist') def test_check_xpath_filter_failure_notification(client, live_server): - set_original_response() - run_filter_test(client, '//*[@id="nope-doesnt-exist"]') + run_filter_test(client, live_server, '//*[@id="nope-doesnt-exist"]') # Test that notification is never sent diff --git a/changedetectionio/update_worker.py b/changedetectionio/update_worker.py index dcb9dbe7..f17d3a28 100644 --- a/changedetectionio/update_worker.py +++ b/changedetectionio/update_worker.py @@ -348,7 +348,7 @@ class update_worker(threading.Thread): # Send notification if we reached the threshold? threshold = self.datastore.data['settings']['application'].get('filter_failure_notification_threshold_attempts', 0) - logger.error(f"Filter for {uuid} not found, consecutive_filter_failures: {c}") + logger.warning(f"Filter for {uuid} not found, consecutive_filter_failures: {c}") if threshold > 0 and c >= threshold: if not self.datastore.data['watching'][uuid].get('notification_muted'): self.send_filter_failure_notification(uuid) @@ -362,7 +362,6 @@ class update_worker(threading.Thread): # Yes fine, so nothing todo, don't continue to process. process_changedetection_results = False changed_detected = False - self.datastore.update_watch(uuid=uuid, update_obj={'last_error': False}) except content_fetchers.exceptions.BrowserConnectError as e: self.datastore.update_watch(uuid=uuid, update_obj={'last_error': e.msg