mirror of
https://github.com/jayofelony/pwnagotchi.git
synced 2025-07-01 18:37:27 -04:00
save backups of brain files when saving
This commit is contained in:
@ -81,6 +81,7 @@ class Stats(object):
|
||||
with open(temp, 'wt') as fp:
|
||||
fp.write(data)
|
||||
|
||||
if os.path.isfile(self.path):
|
||||
os.replace(self.path, back)
|
||||
os.replace(temp, self.path)
|
||||
|
||||
@ -117,6 +118,7 @@ class AsyncTrainer(object):
|
||||
temp = "%s.tmp" % self._nn_path
|
||||
back = "%s.bak" % self._nn_path
|
||||
self._model.save(temp)
|
||||
if os.path.isfile(self._nn_path):
|
||||
os.replace(self._nn_path, back)
|
||||
os.replace(temp, self._nn_path)
|
||||
|
||||
|
Reference in New Issue
Block a user