Skip to content

Commit

Permalink
Merge pull request #192 from rayosborn:fix-backup-modification-time
Browse files Browse the repository at this point in the history
Improves backup restoration
  • Loading branch information
rayosborn authored Jan 13, 2023
2 parents 7fc5084 + bb3b8cd commit a17eaf7
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/nexusformat/nexus/tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -1362,6 +1362,7 @@ def reload(self):
self._root._entries[entry]._group = self._root
self._root._changed = True
self._root._file_modified = False
self._root._mtime = self.mtime

def rename(self, old_path, new_path):
"""Rename an object defined by its path to a new path.
Expand Down Expand Up @@ -5709,7 +5710,7 @@ def restore(self, filename=None, overwrite=False):
"to True")
import shutil
shutil.copy2(self._backup, filename)
self.nxfile = filename
self.reload()

def close(self):
"""Close the underlying HDF5 file."""
Expand Down Expand Up @@ -5777,6 +5778,7 @@ def nxfile(self, filename):
self._entries[entry]._group = self
self._attrs._setattrs(root.attrs)
self._file = NXFile(self._filename, self._mode)
self._mtime = self._file.mtime
self.set_changed()
else:
raise NeXusError(f"'{Path(filename).resolve()}' does not exist")
Expand Down

0 comments on commit a17eaf7

Please sign in to comment.