From 8250bd0b94a8af2f492aed22e48b5d359f979aaf Mon Sep 17 00:00:00 2001 From: Christian Kellner Date: Mon, 20 Jul 2020 18:10:26 +0200 Subject: [PATCH] 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. --- osbuild/objectstore.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/osbuild/objectstore.py b/osbuild/objectstore.py index 3b6529fd..583c6d43 100644 --- a/osbuild/objectstore.py +++ b/osbuild/objectstore.py @@ -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