diff --git a/changedetectionio/processors/text_json_diff/processor.py b/changedetectionio/processors/text_json_diff/processor.py index 42c2dd59..0d5437ec 100644 --- a/changedetectionio/processors/text_json_diff/processor.py +++ b/changedetectionio/processors/text_json_diff/processor.py @@ -331,13 +331,21 @@ class perform_site_check(difference_detection_processor): if result: blocked = True - # The main thing that all this at the moment comes down to :) - if watch.get('previous_md5') != fetched_md5: - changed_detected = True # Looks like something changed, but did it match all the rules? if blocked: changed_detected = False + else: + # The main thing that all this at the moment comes down to :) + if watch.get('previous_md5') != fetched_md5: + changed_detected = True + + # Always record the new checksum + update_obj["previous_md5"] = fetched_md5 + + # On the first run of a site, watch['previous_md5'] will be None, set it the current one. + if not watch.get('previous_md5'): + watch['previous_md5'] = fetched_md5 logger.debug(f"Watch UUID {watch.get('uuid')} content check - Previous MD5: {watch.get('previous_md5')}, Fetched MD5 {fetched_md5}") @@ -357,12 +365,6 @@ class perform_site_check(difference_detection_processor): else: logger.debug(f"check_unique_lines: UUID {watch.get('uuid')} had unique content") - # Always record the new checksum - update_obj["previous_md5"] = fetched_md5 - - # On the first run of a site, watch['previous_md5'] will be None, set it the current one. - if not watch.get('previous_md5'): - watch['previous_md5'] = fetched_md5 # stripped_text_from_html - Everything after filters and NO 'ignored' content return changed_detected, update_obj, stripped_text_from_html diff --git a/changedetectionio/tests/test_block_while_text_present.py b/changedetectionio/tests/test_block_while_text_present.py index 62ecb598..7b5dec9c 100644 --- a/changedetectionio/tests/test_block_while_text_present.py +++ b/changedetectionio/tests/test_block_while_text_present.py @@ -65,11 +65,8 @@ def test_check_block_changedetection_text_NOT_present(client, live_server, measu live_server_setup(live_server) # Use a mix of case in ZzZ to prove it works case-insensitive. ignore_text = "out of stoCk\r\nfoobar" - set_original_ignore_response() - # Give the endpoint time to spin up - time.sleep(1) # Add our URL to the import page test_url = url_for('test_endpoint', _external=True) @@ -127,13 +124,24 @@ def test_check_block_changedetection_text_NOT_present(client, live_server, measu assert b'unviewed' not in res.data assert b'/test-endpoint' in res.data + # 2548 + # Going back to the ORIGINAL should NOT trigger a change + set_original_ignore_response() + client.get(url_for("form_watch_checknow"), follow_redirects=True) + wait_for_all_checks(client) + res = client.get(url_for("index")) + assert b'unviewed' not in res.data + - # Now we set a change where the text is gone, it should now trigger + # Now we set a change where the text is gone AND its different content, it should now trigger set_modified_response_minus_block_text() client.get(url_for("form_watch_checknow"), follow_redirects=True) wait_for_all_checks(client) res = client.get(url_for("index")) assert b'unviewed' in res.data + + + res = client.get(url_for("form_delete", uuid="all"), follow_redirects=True) assert b'Deleted' in res.data