objectstore: also ignore EEXIST when committing

When the tree is committed to the objects directory of the object-
store, it is done via rename(3). The two possible errors that can
be raised in case that a non-empty tree with the same name already
exist is [EEXIST] or [ENOTEMPTY]. The latter was already ignored
but the former was not. At least on btrfs former will be raised

  File "/home/gicmo/Code/src/osbuild/osbuild/objectstore.py",
    os.rename(tree.root, output_tree)
  FileExistsError: [Errno 17] File exists: 'store/tmpyyi3yvie/tree' -> 'store/objects/…'
This commit is contained in:
Christian Kellner 2020-01-27 17:42:51 +01:00 committed by Tom Gundersen
parent 3a40d31bee
commit b5b5e7be29

View file

@ -144,7 +144,7 @@ class ObjectStore:
output_tree = f"{self.objects}/{treesum_hash}"
# if a tree with the same treesum already exist, use that
with suppress_oserror(errno.ENOTEMPTY):
with suppress_oserror(errno.ENOTEMPTY, errno.EEXIST):
os.rename(tree.path, output_tree)
tree.path = output_tree