Skip to content

Commit

Permalink
Closes #2548
Browse files Browse the repository at this point in the history
  • Loading branch information
dgtlmoon committed Oct 14, 2024
1 parent ecafa27 commit 16a85e2
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 13 deletions.
20 changes: 11 additions & 9 deletions changedetectionio/processors/text_json_diff/processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,13 +331,21 @@ def run_changedetection(self, watch):
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}")

Expand All @@ -357,12 +365,6 @@ def run_changedetection(self, watch):
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
16 changes: 12 additions & 4 deletions changedetectionio/tests/test_block_while_text_present.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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

0 comments on commit 16a85e2

Please sign in to comment.