do not overwrite old backup until new backup is done
This commit is contained in:
parent
5ea1ed6d0a
commit
070509c691
@ -1095,7 +1095,10 @@ class NMRMainWindow(QtWidgets.QMainWindow, Ui_BaseWindow):
|
||||
def _autosave(self):
|
||||
# TODO better separate thread may it takes some time to save
|
||||
self.status.setText('Autosave...')
|
||||
NMRWriter(self.management.graphs, self.management.data).export(self.__backup_path)
|
||||
success = NMRWriter(self.management.graphs, self.management.data).export(self.__backup_path.with_suffix('.nmr.0'))
|
||||
if success:
|
||||
self.__backup_path.with_suffix('.nmr.0').rename(self.__backup_path)
|
||||
|
||||
self.status.setText('')
|
||||
|
||||
def check_for_backup(self):
|
||||
|
@ -22,6 +22,11 @@ class NMRWriter:
|
||||
if isinstance(fname, str):
|
||||
fname = Path(fname)
|
||||
|
||||
try:
|
||||
with fname.open(mode='wb') as fh:
|
||||
fh.write(pack('16s', b'NMREVAL' + bytes(__version__, 'utf8')))
|
||||
dump(self._states, fh)
|
||||
return True
|
||||
except Exception as e:
|
||||
print(f'Saving {fname} failed with exception {e.args}')
|
||||
return False
|
||||
|
Loading…
Reference in New Issue
Block a user