objectstore: make objects identifyable
This adds a new `id` property to the ObjectStore.Object, that is meant to reflect the identifer of the Stage to build the contents of it. This will help to transparently access objects that have been built but not committed to the store. Setting the `base_id` of an object will also set its `id`. When the object is then modified via write() the `id` will be set to None, since no the content and the id are out of sync. In the same way, restting an object will reset its `id` to None.
This commit is contained in:
parent
a8783761a1
commit
f7bcec60f4
1 changed files with 4 additions and 0 deletions
|
|
@ -49,6 +49,7 @@ class Object:
|
|||
self._base = None
|
||||
self._workdir = None
|
||||
self._tree = None
|
||||
self.id = None
|
||||
self.store = store
|
||||
self.reset()
|
||||
|
||||
|
|
@ -72,6 +73,7 @@ class Object:
|
|||
def base(self, base_id: Optional[str]):
|
||||
self._init = not base_id
|
||||
self._base = base_id
|
||||
self.id = base_id
|
||||
|
||||
@property
|
||||
def treesum(self) -> str:
|
||||
|
|
@ -97,6 +99,7 @@ class Object:
|
|||
self._check_readers()
|
||||
self._check_writer()
|
||||
self.init()
|
||||
self.id = None
|
||||
with self.tempdir("writer") as target:
|
||||
mount(self._path, target, ro=False)
|
||||
try:
|
||||
|
|
@ -153,6 +156,7 @@ class Object:
|
|||
if self._workdir:
|
||||
self._workdir.cleanup()
|
||||
self._workdir = None
|
||||
self.id = None
|
||||
|
||||
def _check_readers(self):
|
||||
"""Internal: Raise a ValueError if there are readers"""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue