[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [thandy/master] Fix possible race condition with os.path.exists



commit 53e9b2b3c0b10b3b0075da6acc59c032553813b7
Author: Tomás Touceda <chiiph@xxxxxxxxxxxxxx>
Date:   Thu Oct 20 10:54:16 2011 -0300

    Fix possible race condition with os.path.exists
---
 lib/thandy/packagesys/ThpPackages.py |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/lib/thandy/packagesys/ThpPackages.py b/lib/thandy/packagesys/ThpPackages.py
index e4e12f6..da76c6b 100644
--- a/lib/thandy/packagesys/ThpPackages.py
+++ b/lib/thandy/packagesys/ThpPackages.py
@@ -27,8 +27,10 @@ class ThpDB(object):
         if self._thp_db_root is None:
           raise Exception("There is no THP_DB_ROOT variable set")
         dbpath = os.path.join(self._thp_db_root, "pkg-status")
-        if not os.path.exists(dbpath):
+        try:
             os.mkdir(dbpath)
+        except OSError, e:
+            pass
 
     def getPath(self):
         """ Returns the path to the database root """



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits