Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions changedetectionio/tests/test_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,3 +422,28 @@ def test_plaintext_even_if_xml_content_and_can_apply_filters(client, live_server
assert b'<foobar' not in res.data

res = delete_all_watches(client)


def test_last_error_cleared_on_same_checksum(client, live_server, datastore_path):
"""last_error should be cleared even when content is unchanged (checksumFromPreviousCheckWasTheSame path)"""
set_original_response(datastore_path=datastore_path)

uuid = client.application.config.get('DATASTORE').add_watch(url=url_for('test_endpoint', _external=True))

# First check - establishes baseline checksum
client.get(url_for("ui.form_watch_checknow"), follow_redirects=True)
wait_for_all_checks(client)

# Inject a stale last_error directly (simulates a prior failed check)
datastore = client.application.config.get('DATASTORE')
datastore.update_watch(uuid=uuid, update_obj={'last_error': 'Some previous error'})
assert datastore.data['watching'][uuid].get('last_error') == 'Some previous error'

# Second check - same content, so checksumFromPreviousCheckWasTheSame will fire
client.get(url_for("ui.form_watch_checknow"), follow_redirects=True)
wait_for_all_checks(client)

# last_error must be cleared even though no change was detected
assert datastore.data['watching'][uuid].get('last_error') == False

delete_all_watches(client)
3 changes: 3 additions & 0 deletions changedetectionio/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,9 @@ async def async_update_worker(worker_id, q, notification_q, app, datastore, exec
logger.debug(f'[{uuid}] - checksumFromPreviousCheckWasTheSame - Checksum from previous check was the same, nothing todo here.')
# Reset the edited flag since we successfully completed the check
watch.reset_watch_edited_flag()
# Page was fetched successfully - clear any previous error state
datastore.update_watch(uuid=uuid, update_obj={'last_error': False})
cleanup_error_artifacts(uuid, datastore)

except content_fetchers_exceptions.BrowserConnectError as e:
datastore.update_watch(uuid=uuid,
Expand Down
Loading