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.
This commit is contained in:
Christian Kellner 2020-02-18 17:07:06 +01:00 committed by Tom Gundersen
parent be8aafbb90
commit 7720b5508d

View file

@ -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):