diff options
author | Sascha Silbe <sascha-pgp@silbe.org> | 2010-09-13 08:45:18 (GMT) |
---|---|---|
committer | Sascha Silbe <sascha-pgp@silbe.org> | 2010-09-13 08:45:18 (GMT) |
commit | 594427ecabd258ea30de3f92b4096fb6eccfc798 (patch) | |
tree | d8e8887549e76d27af847e6bf0e80ff834e9b995 | |
parent | e41ae62da584578f1a8ccd627db575bf30ba84b6 (diff) |
restore entries in bundle order
When restoring multiple versions of the same entry to a data store with version
support, we need to save parents before children (so the base version needs to
come first). Backup will now write them in the right order, assuming the
timestamp was correct. This should be good enough in practice; if we ever
encountered bundles that are not in the right order (e.g. because the timestamp
was messed with), we will need to implement topological sorting (based on
tree_id, parent_id and version_id).
-rw-r--r-- | restore.py | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -244,7 +244,7 @@ class AsyncRestore(gobject.GObject): self._bundle = zipfile.ZipFile(self._path, 'r') self._check_bundle() - entries = self._get_directories().items() + entries = self._get_directories() num_entries = len(entries) for position, (object_id, file_paths) in enumerate(entries): self._client_check_command() @@ -349,14 +349,17 @@ class AsyncRestore(gobject.GObject): """Get the names of top-level directories in bundle and of their files. """ contents = {} + order = [] for path in self._bundle.namelist(): if path.endswith('/'): continue directory, file_name = path.lstrip('/').split('/', 1) + if directory not in contents: + order.append(directory) contents.setdefault(directory, []).append(file_name) - return contents + return [(directory, contents[directory]) for directory in order] def _install_entry(self, object_id, file_paths): """Reassemble the given entry and save it to the data store. |