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:
parent
be8aafbb90
commit
7720b5508d
1 changed files with 4 additions and 12 deletions
|
|
@ -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):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue