objectstore: re-use Object.export in Object.init
Instead of having a duplication of the invocation of `cp`, once in `init`, once in `export`, re-use the latter in the former: the to be copied object is accessed in the normal way via the store, and then "exported" to the new location. This gets rid of the call to resolve_ref as a nice side effect, which means less poking into the internals of the store.
This commit is contained in:
parent
d1b9304a56
commit
8250bd0b94
1 changed files with 2 additions and 4 deletions
|
|
@ -59,10 +59,8 @@ class Object:
|
||||||
if self._init:
|
if self._init:
|
||||||
return
|
return
|
||||||
|
|
||||||
source = self.store.resolve_ref(self._base)
|
with self.store.new(self._base) as obj:
|
||||||
subprocess.run(["cp", "--reflink=auto", "-a",
|
obj.export(self._tree)
|
||||||
f"{source}/.", self._tree],
|
|
||||||
check=True)
|
|
||||||
self._init = True
|
self._init = True
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue