summaryrefslogtreecommitdiff
path: root/obnamlib/fmt_ga/tree.py
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2015-07-08 18:39:40 +0300
committerLars Wirzenius <liw@liw.fi>2015-07-08 18:39:40 +0300
commitf97e1d96f9466e80dbb79fe72f5a51c484d1e860 (patch)
tree5cd986a2df4dfcdda0257ad016ea4269d12992ac /obnamlib/fmt_ga/tree.py
parenteefe94bb32e7bb9371c78fb1067d9c618088d17a (diff)
downloadobnam-f97e1d96f9466e80dbb79fe72f5a51c484d1e860.tar.gz
Refactor set_directory for clarity
Diffstat (limited to 'obnamlib/fmt_ga/tree.py')
-rw-r--r--obnamlib/fmt_ga/tree.py15
1 files changed, 8 insertions, 7 deletions
diff --git a/obnamlib/fmt_ga/tree.py b/obnamlib/fmt_ga/tree.py
index f750f52e..57c14920 100644
--- a/obnamlib/fmt_ga/tree.py
+++ b/obnamlib/fmt_ga/tree.py
@@ -83,17 +83,18 @@ class GATree(object):
def set_directory(self, pathname, dir_obj):
self._cache.set(pathname, dir_obj)
if pathname != '/':
- parent_path = os.path.dirname(pathname)
- parent_obj = self.get_directory(parent_path)
+ parent_obj = self._get_containing_dir_obj(pathname)
if not parent_obj:
- parent_obj = self._create_fake_parent(
- os.path.basename(pathname), dir_obj)
- self.set_directory(parent_path, parent_obj)
+ self._create_fake_parent(pathname, dir_obj)
- def _create_fake_parent(self, subdir_basename, subdir_obj):
+ def _create_fake_parent(self, subdir_path, subdir_obj):
+ parent_path = os.path.dirname(subdir_path)
parent_obj = obnamlib.GADirectory()
+
+ subdir_basename = os.path.basename(subdir_path)
parent_obj.add_subdir(subdir_basename, None)
- return parent_obj
+
+ self.set_directory(parent_path, parent_obj)
def flush(self):
self._root_dir_id = self._fixup_subdir_refs('/')