diff --git a/taskflow/persistence/backends/impl_dir.py b/taskflow/persistence/backends/impl_dir.py index f91c4e72a..9d7b3ca23 100644 --- a/taskflow/persistence/backends/impl_dir.py +++ b/taskflow/persistence/backends/impl_dir.py @@ -136,9 +136,13 @@ class Connection(path_based.PathBasedConnection): shutil.rmtree(path) def _get_children(self, path): + if path == self.book_path: + filter_func = os.path.isdir + else: + filter_func = os.path.islink with _storagefailure_wrapper(): - return [link for link in os.listdir(path) - if os.path.islink(self._join_path(path, link))] + return [child for child in os.listdir(path) + if filter_func(self._join_path(path, child))] def _ensure_path(self, path): with _storagefailure_wrapper(): diff --git a/taskflow/tests/unit/persistence/base.py b/taskflow/tests/unit/persistence/base.py index 0b56617fe..f5a20bd0a 100644 --- a/taskflow/tests/unit/persistence/base.py +++ b/taskflow/tests/unit/persistence/base.py @@ -69,6 +69,27 @@ class PersistenceTestMixin(object): self.assertIsNotNone(lb2.find(fd.uuid)) self.assertIsNotNone(lb2.find(fd2.uuid)) + def test_logbook_save_retrieve_many(self): + lb_ids = {} + for i in range(0, 10): + lb_id = uuidutils.generate_uuid() + lb_name = 'lb-%s-%s' % (i, lb_id) + lb = models.LogBook(name=lb_name, uuid=lb_id) + lb_ids[lb_id] = True + + # Should not already exist + with contextlib.closing(self._get_connection()) as conn: + self.assertRaises(exc.NotFound, conn.get_logbook, lb_id) + conn.save_logbook(lb) + + # Now fetch them all + with contextlib.closing(self._get_connection()) as conn: + lbs = conn.get_logbooks() + for lb in lbs: + self.assertIn(lb.uuid, lb_ids) + lb_ids.pop(lb.uuid) + self.assertEqual(0, len(lb_ids)) + def test_logbook_save_retrieve(self): lb_id = uuidutils.generate_uuid() lb_meta = {'1': 2}