diff options
author | 2016-02-21 20:05:51 +0100 | |
---|---|---|
committer | 2016-02-28 22:32:05 -0500 | |
commit | 25055a418980e984b26ca29dd5d6f7cad8df3de8 (patch) | |
tree | 8cc4112e58488e4e56da504cabbc302e50a08707 | |
parent | zsh-completion: add -a/--all for `pclean tmp` (diff) | |
download | pkgcore-25055a418980e984b26ca29dd5d6f7cad8df3de8.tar.gz pkgcore-25055a418980e984b26ca29dd5d6f7cad8df3de8.tar.bz2 pkgcore-25055a418980e984b26ca29dd5d6f7cad8df3de8.zip |
Fix rmdir() to cover potential errno.EEXIST on non-empty dirs
Fix rmdir() uses to cover both the possibility of errno.ENOTEMPTY
and errno.EEXIST for non-empty directories. This behavior (either error)
is specified by POSIX, and Solaris returns EEXIST rather than ENOTEMPTY.
-rw-r--r-- | pkgcore/binpkg/repository.py | 5 | ||||
-rw-r--r-- | pkgcore/ebuild/ebd.py | 10 | ||||
-rw-r--r-- | pkgcore/vdb/ondisk.py | 5 |
3 files changed, 16 insertions, 4 deletions
diff --git a/pkgcore/binpkg/repository.py b/pkgcore/binpkg/repository.py index 54d494af0..8c83b203a 100644 --- a/pkgcore/binpkg/repository.py +++ b/pkgcore/binpkg/repository.py @@ -350,7 +350,10 @@ class tree(prototype.tree): try: os.rmdir(pjoin(self.base, pkg.category)) except OSError as oe: - if oe.errno != errno.ENOTEMPTY: + # POSIX specifies either ENOTEMPTY or EEXIST for non-empty dir + # in particular, Solaris uses EEXIST in that case. + # https://github.com/pkgcore/pkgcore/pull/181 + if oe.errno not in (errno.ENOTEMPTY, errno.EEXIST): raise del oe diff --git a/pkgcore/ebuild/ebd.py b/pkgcore/ebuild/ebd.py index 2dccd45a1..8b1fdf777 100644 --- a/pkgcore/ebuild/ebd.py +++ b/pkgcore/ebuild/ebd.py @@ -333,7 +333,10 @@ class ebd(object): try: os.rmdir(os.path.dirname(self.builddir)) except EnvironmentError as e: - if e.errno != errno.ENOTEMPTY: + # POSIX specifies either ENOTEMPTY or EEXIST for non-empty dir + # in particular, Solaris uses EEXIST in that case. + # https://github.com/pkgcore/pkgcore/pull/181 + if e.errno not in (errno.ENOTEMPTY, errno.EEXIST): raise except EnvironmentError as e: raise_from(format.GenericBuildError( @@ -894,7 +897,10 @@ class ebuild_mixin(object): try: os.rmdir(os.path.dirname(builddir)) except EnvironmentError as e: - if e.errno != errno.ENOTEMPTY: + # POSIX specifies either ENOTEMPTY or EEXIST for non-empty dir + # in particular, Solaris uses EEXIST in that case. + # https://github.com/pkgcore/pkgcore/pull/181 + if e.errno not in (errno.ENOTEMPTY, errno.EEXIST): raise diff --git a/pkgcore/vdb/ondisk.py b/pkgcore/vdb/ondisk.py index dbdbd18f1..b82627611 100644 --- a/pkgcore/vdb/ondisk.py +++ b/pkgcore/vdb/ondisk.py @@ -187,7 +187,10 @@ class tree(prototype.tree): try: os.rmdir(pjoin(self.location, pkg.category)) except OSError as oe: - if oe.errno != errno.ENOTEMPTY: + # POSIX specifies either ENOTEMPTY or EEXIST for non-empty dir + # in particular, Solaris uses EEXIST in that case. + # https://github.com/pkgcore/pkgcore/pull/181 + if oe.errno not in (errno.ENOTEMPTY, errno.EEXIST): raise # silently swallow it; del oe |