summaryrefslogtreecommitdiff
path: root/taskflow
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2015-06-15 23:22:52 +0000
committerGerrit Code Review <review@openstack.org>2015-06-15 23:22:52 +0000
commitd2c01658d052a4f48c5bcba1cf09bb13ca747329 (patch)
tree960d2fdf2b3757e8dc784c33896b1267fef4a016 /taskflow
parenta3f8f1f198126fb013e3ac5252bc4780124f628b (diff)
parent24752c204b418014e72c4ad9909200085155623d (diff)
downloadtaskflow-d2c01658d052a4f48c5bcba1cf09bb13ca747329.tar.gz
Merge "Use hash path lookup vs path finding"0.11.0
Diffstat (limited to 'taskflow')
-rw-r--r--taskflow/persistence/backends/impl_memory.py23
1 files changed, 11 insertions, 12 deletions
diff --git a/taskflow/persistence/backends/impl_memory.py b/taskflow/persistence/backends/impl_memory.py
index 43207b8..22a0652 100644
--- a/taskflow/persistence/backends/impl_memory.py
+++ b/taskflow/persistence/backends/impl_memory.py
@@ -274,14 +274,13 @@ class FakeFilesystem(object):
"""Link the destionation path to the source path."""
dest_path = self.normpath(dest_path)
src_path = self.normpath(src_path)
- dirname, basename = self.split(dest_path)
- parent_node = self._fetch_node(dirname, normalized=True)
- child_node = parent_node.find(basename,
- only_direct=True,
- include_self=False)
- if child_node is None:
- child_node = self._insert_child(parent_node, basename)
- child_node.metadata['target'] = src_path
+ try:
+ dest_node = self._fetch_node(dest_path, normalized=True)
+ except exc.NotFound:
+ parent_path, basename = self.split(dest_path)
+ parent_node = self._fetch_node(parent_path, normalized=True)
+ dest_node = self._insert_child(parent_node, basename)
+ dest_node.metadata['target'] = src_path
def __getitem__(self, path):
return self._get_item(self.normpath(path))
@@ -290,11 +289,11 @@ class FakeFilesystem(object):
path = self.normpath(path)
value = self._copier(value)
try:
- item_node = self._fetch_node(path, normalized=True)
- item_node.metadata.update(value=value)
+ node = self._fetch_node(path, normalized=True)
+ node.metadata.update(value=value)
except exc.NotFound:
- dirname, basename = self.split(path)
- parent_node = self._fetch_node(dirname, normalized=True)
+ parent_path, basename = self.split(path)
+ parent_node = self._fetch_node(parent_path, normalized=True)
self._insert_child(parent_node, basename, value=value)