fixes
Some checks are pending
🐳 ⚠ docker-unsafe from next_release branch / docker_dev_unsafe (push) Waiting to run

This commit is contained in:
Jokob @NetAlertX
2026-04-13 13:02:34 +00:00
parent 8abecb7a0d
commit c275bf447d
2 changed files with 28 additions and 3 deletions

View File

@@ -817,13 +817,15 @@ def process_plugin_events(db, plugin, plugEventsArr):
pluginObjects.append(tmpObjFromEvent)
# update data of existing objects
else:
if tmpObjFromEvent.status == "watched-changed":
changed_this_cycle.add(tmpObjFromEvent.idsHash)
index = 0
for plugObj in pluginObjects:
# find corresponding object for the event and merge
if plugObj.idsHash == tmpObjFromEvent.idsHash:
if (
plugObj.status == "missing-in-last-scan"
or tmpObjFromEvent.status == "watched-changed"
):
changed_this_cycle.add(tmpObjFromEvent.idsHash)
pluginObjects[index] = combine_plugin_objects(
plugObj, tmpObjFromEvent
)

View File

@@ -211,3 +211,26 @@ class TestHistoryOnlyRecordsChanges:
objs = plugin_objects_rows(conn, PREFIX)
assert len(objs) == 1, "Plugins_Objects should still have the object"
def test_recovery_from_missing_recorded(self, plugin_db, monkeypatch):
"""An object that was missing-in-last-scan and reappears (even with
unchanged watched values) should produce a history row."""
db, conn = plugin_db
monkeypatch.setattr("plugin.get_setting_value", _no_report_on)
cur = conn.cursor()
seed_plugin_object(cur, PREFIX, "device_A", watched1="val1",
status="missing-in-last-scan")
conn.commit()
plugin = make_plugin_dict(PREFIX)
# device_A reappears with the same watched value
events = [make_plugin_event_row(PREFIX, "device_A", watched1="val1")]
process_plugin_events(db, plugin, events)
rows = plugin_history_rows(conn, PREFIX)
assert len(rows) == 1, (
"recovery from missing-in-last-scan should generate a history row"
)
assert rows[0][2] == "device_A"