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:
Christian Kellner 2020-07-20 18:10:26 +02:00 committed by Tom Gundersen
parent d1b9304a56
commit 8250bd0b94

View file

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