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:
|
||||
return
|
||||
|
||||
source = self.store.resolve_ref(self._base)
|
||||
subprocess.run(["cp", "--reflink=auto", "-a",
|
||||
f"{source}/.", self._tree],
|
||||
check=True)
|
||||
with self.store.new(self._base) as obj:
|
||||
obj.export(self._tree)
|
||||
self._init = True
|
||||
|
||||
@property
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue