diff options
author | 2013-02-15 14:17:31 -0400 | |
---|---|---|
committer | 2013-02-15 14:17:31 -0400 | |
commit | e90f68e11df1c6b72d34d1835f64b6b912156936 (patch) | |
tree | fccbbca86e3eefa36adbadac7f7e76b8c6008297 /Init.hs | |
parent | a3d5e1178d80b294a8607aa3b21325730cb424d9 (diff) |
don't allow setting indirect mode on a crippled filesystem
Diffstat (limited to 'Init.hs')
-rw-r--r-- | Init.hs | 21 |
1 files changed, 13 insertions, 8 deletions
@@ -9,7 +9,8 @@ module Init ( ensureInitialized, isInitialized, initialize, - uninitialize + uninitialize, + probeCrippledFileSystem ) where import Common.Annex @@ -37,7 +38,7 @@ genDescription Nothing = do initialize :: Maybe String -> Annex () initialize mdescription = do prepUUID - probeCrippledFileSystem + checkCrippledFileSystem Annex.Branch.create setVersion gitPreCommitHookWrite @@ -102,18 +103,16 @@ preCommitScript = unlines , "git annex pre-commit ." ] -probeCrippledFileSystem :: Annex () +probeCrippledFileSystem :: Annex Bool probeCrippledFileSystem = do tmp <- fromRepo gitAnnexTmpDir - let f = tmp </> "init-probe" + let f = tmp </> "gaprobe" liftIO $ do createDirectoryIfMissing True tmp writeFile f "" - whenM (liftIO $ not <$> probe f) $ do - warning "Detected a crippled filesystem. Enabling direct mode." - setDirect True - setCrippledFileSystem True + uncrippled <- liftIO $ probe f liftIO $ removeFile f + return $ not uncrippled where probe f = catchBoolIO $ do let f2 = f ++ "2" @@ -125,3 +124,9 @@ probeCrippledFileSystem = do preventWrite f allowWrite f return True + +checkCrippledFileSystem :: Annex () +checkCrippledFileSystem = whenM (probeCrippledFileSystem) $ do + warning "Detected a crippled filesystem. Enabling direct mode." + setDirect True + setCrippledFileSystem True |