objectstore: option to clone object on commit
Add a new `clone` parameter to the `commit` method on `ObjectStore` that when used will clone the object to the store instead of using the `store_tree` method which moves the object and resets it. This is the first step of removing copy-on-write support from `Object`.
This commit is contained in:
parent
1762048c1f
commit
daa2e1c3bb
1 changed files with 6 additions and 2 deletions
|
|
@ -308,7 +308,7 @@ class ObjectStore(contextlib.AbstractContextManager):
|
|||
|
||||
return obj
|
||||
|
||||
def commit(self, obj: Object, object_id: str) -> str:
|
||||
def commit(self, obj: Object, object_id: str, clone: bool = False) -> str:
|
||||
"""Commits a Object to the object store
|
||||
|
||||
Move the contents of the obj (Object) to object directory
|
||||
|
|
@ -323,7 +323,11 @@ class ObjectStore(contextlib.AbstractContextManager):
|
|||
# The object is stored in the objects directory using its unique
|
||||
# name. This means that each commit will always result in a new
|
||||
# object in the store, even if an identical one exists.
|
||||
object_name = obj.store_tree()
|
||||
if clone:
|
||||
object_name = str(uuid.uuid4())
|
||||
obj.clone(os.path.join(self.objects, object_name))
|
||||
else:
|
||||
object_name = obj.store_tree()
|
||||
|
||||
# symlink the object_id (config hash) in the refs directory to the
|
||||
# object name in the objects directory. If a symlink by that name
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue