Skip to content

Commit 16a85e2

Browse files
committed
Closes #2548
1 parent ecafa27 commit 16a85e2

File tree

2 files changed

+23
-13
lines changed

2 files changed

+23
-13
lines changed

changedetectionio/processors/text_json_diff/processor.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -331,13 +331,21 @@ def run_changedetection(self, watch):
331331
if result:
332332
blocked = True
333333

334-
# The main thing that all this at the moment comes down to :)
335-
if watch.get('previous_md5') != fetched_md5:
336-
changed_detected = True
337334

338335
# Looks like something changed, but did it match all the rules?
339336
if blocked:
340337
changed_detected = False
338+
else:
339+
# The main thing that all this at the moment comes down to :)
340+
if watch.get('previous_md5') != fetched_md5:
341+
changed_detected = True
342+
343+
# Always record the new checksum
344+
update_obj["previous_md5"] = fetched_md5
345+
346+
# On the first run of a site, watch['previous_md5'] will be None, set it the current one.
347+
if not watch.get('previous_md5'):
348+
watch['previous_md5'] = fetched_md5
341349

342350
logger.debug(f"Watch UUID {watch.get('uuid')} content check - Previous MD5: {watch.get('previous_md5')}, Fetched MD5 {fetched_md5}")
343351

@@ -357,12 +365,6 @@ def run_changedetection(self, watch):
357365
else:
358366
logger.debug(f"check_unique_lines: UUID {watch.get('uuid')} had unique content")
359367

360-
# Always record the new checksum
361-
update_obj["previous_md5"] = fetched_md5
362-
363-
# On the first run of a site, watch['previous_md5'] will be None, set it the current one.
364-
if not watch.get('previous_md5'):
365-
watch['previous_md5'] = fetched_md5
366368

367369
# stripped_text_from_html - Everything after filters and NO 'ignored' content
368370
return changed_detected, update_obj, stripped_text_from_html

changedetectionio/tests/test_block_while_text_present.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,8 @@ def test_check_block_changedetection_text_NOT_present(client, live_server, measu
6565
live_server_setup(live_server)
6666
# Use a mix of case in ZzZ to prove it works case-insensitive.
6767
ignore_text = "out of stoCk\r\nfoobar"
68-
6968
set_original_ignore_response()
7069

71-
# Give the endpoint time to spin up
72-
time.sleep(1)
7370

7471
# Add our URL to the import page
7572
test_url = url_for('test_endpoint', _external=True)
@@ -127,13 +124,24 @@ def test_check_block_changedetection_text_NOT_present(client, live_server, measu
127124
assert b'unviewed' not in res.data
128125
assert b'/test-endpoint' in res.data
129126

127+
# 2548
128+
# Going back to the ORIGINAL should NOT trigger a change
129+
set_original_ignore_response()
130+
client.get(url_for("form_watch_checknow"), follow_redirects=True)
131+
wait_for_all_checks(client)
132+
res = client.get(url_for("index"))
133+
assert b'unviewed' not in res.data
134+
130135

131-
# Now we set a change where the text is gone, it should now trigger
136+
# Now we set a change where the text is gone AND its different content, it should now trigger
132137
set_modified_response_minus_block_text()
133138
client.get(url_for("form_watch_checknow"), follow_redirects=True)
134139
wait_for_all_checks(client)
135140
res = client.get(url_for("index"))
136141
assert b'unviewed' in res.data
137142

143+
144+
145+
138146
res = client.get(url_for("form_delete", uuid="all"), follow_redirects=True)
139147
assert b'Deleted' in res.data

0 commit comments

Comments
 (0)