From 50233460b2efdeff5cd14efa74e6f19d1b32914d Mon Sep 17 00:00:00 2001 From: dlgreenwald Date: Fri, 4 Aug 2023 15:07:27 -0400 Subject: [PATCH] Mitigate race condition in update_device_names --- pialert/device.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pialert/device.py b/pialert/device.py index 2d267b34..b2217d89 100755 --- a/pialert/device.py +++ b/pialert/device.py @@ -451,7 +451,10 @@ def update_devices_names (db): # isf still not found update name so we can distinguish the devices where we tried already if newName == -1 : - recordsNotFound.append (["(name not found)", device['dev_MAC']]) + # if dev_Name is the same as what we will change it to, take no action + # this mitigates a race condition which would overwrite a users edits that occured since the select earlier + if device['dev_Name'] != "(name not found)": + recordsNotFound.append (["(name not found)", device['dev_MAC']]) else: # name wa sfound with DiG or Pholus recordsToUpdate.append ([newName, device['dev_MAC']])