From 1762048c1f2ebfa22e91fc1c04b58dd002056760 Mon Sep 17 00:00:00 2001 From: Christian Kellner Date: Fri, 19 Aug 2022 18:13:15 +0200 Subject: [PATCH] objectstore: add clone method for object Right now this is basically a clone(!) of `export` but this will change in the future when we change the layout of how objects are stored. --- osbuild/objectstore.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/osbuild/objectstore.py b/osbuild/objectstore.py index 642ffd7f..46d7e393 100644 --- a/osbuild/objectstore.py +++ b/osbuild/objectstore.py @@ -184,6 +184,20 @@ class Object: check=True, ) + def clone(self, to_directory: PathLike): + """Clone the object to the specified directory""" + with self.read() as from_directory: + subprocess.run( + [ + "cp", + "--reflink=auto", + "-a", + os.fspath(from_directory) + "/.", + os.fspath(to_directory), + ], + check=True, + ) + class HostTree: """Read-only access to the host file system