Make atomic directory creation code in dblink.mergeme() use equivalent
authorZac Medico <zmedico@gentoo.org>
Wed, 1 Sep 2010 16:00:48 +0000 (09:00 -0700)
committerZac Medico <zmedico@gentoo.org>
Wed, 1 Sep 2010 16:00:48 +0000 (09:00 -0700)
error handling to portage.util.ensure_dirs().

pym/portage/dbapi/vartree.py

index 45ed955ede95f44a6e88297ee97f8038403b21a6..25956f198252160ffa67fdf320d2dbcefa661d72 100644 (file)
@@ -3619,8 +3619,14 @@ class dblink(object):
                                                        else:
                                                                os.mkdir(mydest)
                                                except OSError as e:
-                                                       if e.errno not in (errno.EEXIST, errno.EISDIR):
-                                                               # Bug 187518 - sometimes mkdir raises EISDIR on FreeBSD
+                                                       # Error handling should be equivalent to
+                                                       # portage.util.ensure_dirs() for cases
+                                                       # like bug #187518.
+                                                       if e.errno in (errno.EEXIST,):
+                                                               pass
+                                                       elif os.path.isdir(mydest):
+                                                               pass
+                                                       else:
                                                                raise
                                                        del e
 
@@ -3637,8 +3643,14 @@ class dblink(object):
                                                else:
                                                        os.mkdir(mydest)
                                        except OSError as e:
-                                               if e.errno not in (errno.EEXIST, errno.EISDIR):
-                                                       # Bug 187518 - sometimes mkdir raises EISDIR on FreeBSD
+                                               # Error handling should be equivalent to
+                                               # portage.util.ensure_dirs() for cases
+                                               # like bug #187518.
+                                               if e.errno in (errno.EEXIST,):
+                                                       pass
+                                               elif os.path.isdir(mydest):
+                                                       pass
+                                               else:
                                                        raise
                                                del e
                                        os.chmod(mydest, mystat[0])