From 52736169f1998a89c322596c2b0a979f1e0ca26d Mon Sep 17 00:00:00 2001 From: Christian Kellner Date: Wed, 26 Feb 2020 14:09:18 +0100 Subject: [PATCH] objectstore: Object keeps reference to store Keep are reference to the parent store, which this object is tied to. It is currently not yet used directly but is a preparation for a closer Object and ObjectStore integration that will happen in commits to follow. --- osbuild/objectstore.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/osbuild/objectstore.py b/osbuild/objectstore.py index 0738566c..627cc70f 100644 --- a/osbuild/objectstore.py +++ b/osbuild/objectstore.py @@ -28,7 +28,8 @@ def suppress_oserror(*errnos): class Object: - def __init__(self, path: str): + def __init__(self, store: "ObjectStore", path: str): + self.store = store os.makedirs(path, mode=0o755, exist_ok=True) self.path = path @@ -113,7 +114,7 @@ class ObjectStore: with tempfile.TemporaryDirectory(dir=self.store) as tmp: # the object that is yielded will be added to the content store # on success as object_id - obj = Object(f"{tmp}/tree") + obj = Object(self, f"{tmp}/tree") if base_id: # the base, the working tree and the output dir are all @@ -143,7 +144,7 @@ class ObjectStore: # the latter with the contents of `object_path` and commit # it to the store with tempfile.TemporaryDirectory(dir=self.store) as tmp: - obj = Object(f"{tmp}/tree") + obj = Object(self, f"{tmp}/tree") obj.init(object_path) return self.commit(obj, object_id)