one more try to get sane behavior our of lustre
authorJoey Hess <joeyh@joeyh.name>
Fri, 13 Nov 2015 19:51:45 +0000 (15:51 -0400)
committerJoey Hess <joeyh@joeyh.name>
Fri, 13 Nov 2015 19:51:45 +0000 (15:51 -0400)
Utility/LockFile/PidLock.hs

index 68d9b7bac2ef50828777b82bae9dee5d60606a52..5c5a89cc75d575a1dc19de0c92494844b60b27fe 100644 (file)
@@ -144,8 +144,11 @@ tryLock lockfile = trySideLock lockfile $ \sidelock -> do
 linkToLock :: SideLockHandle -> FilePath -> FilePath -> IO Bool
 linkToLock Nothing _ _ = return False
 linkToLock (Just _) src dest = do
+       -- This might make Lustre notice that a lock file that is already
+       -- there is there?
+       _ <- catchMaybeIO $ readFile dest
        _ <- tryIO $ createLink src dest
-       ifM (catchBoolIO checklink)
+       ifM (catchBoolIO checklinked)
                ( catchBoolIO $ do
                        srccontent <- readFile src
                        destcontent <- readFile dest
@@ -153,7 +156,7 @@ linkToLock (Just _) src dest = do
                , return False
                )
   where
-       checklink = do
+       checklinked = do
                x <- getSymbolicLinkStatus src
                y <- getSymbolicLinkStatus dest
                return $ and