Fix updating repeaterbook cache on windows

Apparently windows can't do atomic rename, which means we have to
remove and rename (and hope we don't fail in between).

Fixes #10479
This commit is contained in:
Dan Smith 2023-03-26 17:55:06 -07:00 committed by Dan Smith
parent e6473aa729
commit 37d8b94de2

View file

@ -147,7 +147,12 @@ class RepeaterBook(base.NetworkResultRadio):
return
if results['count']:
os.rename(tmp, data_file)
try:
os.rename(tmp, data_file)
except FileExistsError:
# Windows can't do atomic rename
os.remove(data_file)
os.rename(tmp, data_file)
else:
os.remove(tmp)
status.send_fail('No results!')