diff options
author | Lars Wirzenius <liw@liw.fi> | 2013-12-08 18:53:56 +0000 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2013-12-28 21:51:24 +0000 |
commit | 8f6107857adfe177aaf72f3ca844640c83a9a57e (patch) | |
tree | a6e5b156921a82ca81d38d0cf5e064f16477e5ff /obnamlib/plugins/restore_plugin.py | |
parent | 99bd16c5b512eb6994b71941d2d027bbc8673d5e (diff) | |
download | obnam-8f6107857adfe177aaf72f3ca844640c83a9a57e.tar.gz |
Construct a Metadata object when restoring
Diffstat (limited to 'obnamlib/plugins/restore_plugin.py')
-rw-r--r-- | obnamlib/plugins/restore_plugin.py | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/obnamlib/plugins/restore_plugin.py b/obnamlib/plugins/restore_plugin.py index 04082f4c..a91f6070 100644 --- a/obnamlib/plugins/restore_plugin.py +++ b/obnamlib/plugins/restore_plugin.py @@ -179,14 +179,43 @@ class RestorePlugin(obnamlib.ObnamPlugin): for pathname in self.repo_walk(gen, root, depth_first=True): self.file_count += 1 self.app.ts['current'] = pathname - self.restore_safely(gen, pathname, metadata) + self.restore_safely(gen, pathname) - def restore_safely(self, gen, pathname, metadata): + def construct_metadata_object(self, gen, filename): + allowed = set(self.repo.get_allowed_file_keys()) + def K(key): + if key in allowed: + return self.repo.get_file_key(gen, filename, key) + else: + return None + + return obnamlib.Metdata( + st_atime_sec=K(obnamlib.REPO_FILE_ATIME_SEC), + st_atime_nsec=K(obnamlib.REPO_FILE_ATIME_NSEC), + st_mtime_sec=K(obnamlib.REPO_FILE_MTIME_NSEC), + st_mtime_nsec=K(obnamlib.REPO_FILE_MTIME_NSEC), + st_blocks=K(obnamlib.REPO_FILE_BLOCKS), + st_dev=K(obnamlib.REPO_FILE_DEV), + st_gid=K(obnamlib.REPO_FILE_GID), + st_ino=K(obnamlib.REPO_FILE_INO), + st_mode=K(obnamlib.REPO_FILE_MODE), + st_nlink=K(obnamlib.REPO_FILE_NLINK), + st_size=K(obnamlib.REPO_FILE_SIZE), + st_uid=K(obnamlib.REPO_FILE_UID), + username=K(obnamlib.REPO_FILE_USERNAME), + groupname=K(obnamlib.REPO_FILE_GROUPNAME), + target=K(obnamlib.REPO_FILE_SYMLINK_TARGET), + xattr=K(obnamlib.REPO_FILE_XATTR), + ) + + def restore_safely(self, gen, pathname): try: dirname = os.path.dirname(pathname) if self.write_ok and not self.fs.exists('./' + dirname): self.fs.makedirs('./' + dirname) + metadata = self.construct_metadata_object(gen, pathname) + set_metadata = True if metadata.isdir(): self.restore_dir(gen, pathname, metadata) |