From 7720b5508da659dd033961e0b250c72fa8586b6d Mon Sep 17 00:00:00 2001 From: Christian Kellner Date: Tue, 18 Feb 2020 17:07:06 +0100 Subject: [PATCH] objectstore: refactor .get() to use Object Instead of using custom bind-mount based logic in ObjectStore.get, use a combination of Object + `Object.read` with the supplied base (that can be None), which will lead to exactly the same outcome. --- osbuild/objectstore.py | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/osbuild/objectstore.py b/osbuild/objectstore.py index 5faf6b76..924405d9 100644 --- a/osbuild/objectstore.py +++ b/osbuild/objectstore.py @@ -210,18 +210,10 @@ class ObjectStore: @contextlib.contextmanager def get(self, object_id): - with self.tempdir() as tmp: - if object_id: - path = self.resolve_ref(object_id) - mount(path, tmp) - try: - yield tmp - finally: - umount(tmp) - else: - # None was given as object_id, just return an empty directory - yield tmp - + with Object(self) as obj: + obj.base = object_id + with obj.read() as path: + yield path @contextlib.contextmanager def new(self, object_id, base_id=None):