workdir: create tmpfiles in the correct directory
authorSteven Walter <swalter@lpdev.prtdev.lexmark.com>
Wed, 3 Dec 2008 21:13:38 +0000 (3 16:13 -0500)
committerSteven Walter <swalter@lpdev.prtdev.lexmark.com>
Wed, 3 Dec 2008 21:13:38 +0000 (3 16:13 -0500)
plugins/workdir.py

index f6c1bec..f9b4353 100644 (file)
@@ -34,7 +34,7 @@ class WorkdirPlugin(YapCore):
         except OSError:
             pass
 
-        fd, tmplock = tempfile.mkstemp("yap")
+        fd, tmplock = tempfile.mkstemp("yap", dir=dir)
         os.write(fd, locked_by)
         os.close(fd)
         while True:
@@ -42,8 +42,11 @@ class WorkdirPlugin(YapCore):
             try:
                 os.link(tmplock, lockfile)
                 break
-            except OSError:
-                fd = file(lockfile)
+            except OSError, e:
+               try:
+                   fd = file(lockfile)
+               except:
+                   raise e
                 user = fd.readline()
                 # If the workdir has been deleted, break his lock
                 if os.access(user, os.R_OK):