osbuild: check for right errno from os.rename()
Renaming a directory over an existing one is only an error if the
existing one is not empty, in which case ENOEMPTY is thrown.
Tested with:
>>> os.mkdir("foo")
>>> os.mkdir("bar")
>>> os.rename("foo", "bar")
# no error
>>> open("foo/a", "w").write("a")
1
>>> try: os.rename("bar", "foo")
... except OSError as e: e.errno == errno.ENOTEMPTY
...
True
This commit is contained in:
parent
054fea3d83
commit
68832d2aaf
1 changed files with 1 additions and 1 deletions
|
|
@ -188,7 +188,7 @@ class ObjectStore:
|
|||
try:
|
||||
os.rename(tree, output_tree)
|
||||
except OSError as e:
|
||||
if e.errno == errno.EEXIST:
|
||||
if e.errno == errno.ENOTEMPTY:
|
||||
pass # tree with the same content hash already exist, use that
|
||||
else:
|
||||
raise
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue