summaryrefslogtreecommitdiff
path: root/Assistant/Threads
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2014-05-30 15:08:49 -0400
committerGravatar Joey Hess <joey@kitenet.net>2014-05-30 15:08:49 -0400
commite9459ce34db199a12acf6f8f0c0a610384e2f000 (patch)
tree5301c41e8e77f47fecbd9bb5eab509f4524269f3 /Assistant/Threads
parentf3de5fd2959f258d35a73b9c9a81d7a95bf7f61f (diff)
assistant: Make sanity checker tmp dir cleanup code more robust.
Diffstat (limited to 'Assistant/Threads')
-rw-r--r--Assistant/Threads/SanityChecker.hs15
1 files changed, 9 insertions, 6 deletions
diff --git a/Assistant/Threads/SanityChecker.hs b/Assistant/Threads/SanityChecker.hs
index ba141698d..c4f2723f0 100644
--- a/Assistant/Threads/SanityChecker.hs
+++ b/Assistant/Threads/SanityChecker.hs
@@ -40,6 +40,7 @@ import Logs.Transfer
import Config.Files
import Utility.DiskFree
import qualified Annex
+import Annex.Exception
#ifdef WITH_WEBAPP
import Assistant.WebApp.Types
#endif
@@ -84,8 +85,9 @@ sanityCheckerStartupThread startupdelay = namedThreadUnchecked "SanityCheckerSta
liftIO $ fixUpSshRemotes
{- Clean up old temp files. -}
- liftAnnex cleanOldTmpMisc
- liftAnnex cleanReallyOldTmp
+ void $ liftAnnex $ tryAnnex $ do
+ cleanOldTmpMisc
+ cleanReallyOldTmp
{- If there's a startup delay, it's done here. -}
liftIO $ maybe noop (threadDelaySeconds . Seconds . fromIntegral . durationSeconds) startupdelay
@@ -310,7 +312,8 @@ cleanReallyOldTmp = do
| otherwise -> noop
cleanOld :: (POSIXTime -> Bool) -> FilePath -> IO ()
-cleanOld check f = do
- mtime <- realToFrac . modificationTime <$> getFileStatus f
- when (check mtime) $
- nukeFile f
+cleanOld check f = go =<< catchMaybeIO getmtime
+ where
+ getmtime = realToFrac . modificationTime <$> getSymbolicLinkStatus f
+ go (Just mtime) | check mtime = nukeFile f
+ go _ = noop