summaryrefslogtreecommitdiff
path: root/Init.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2013-02-14 14:10:36 -0400
committerGravatar Joey Hess <joey@kitenet.net>2013-02-14 14:15:26 -0400
commit177245deb6ee3271eb44d77c2b0cd722755b2c3f (patch)
tree876c4844937c831470192d367123f581fb6cc3d8 /Init.hs
parent4e2d50d2e4c9b4d3487c24042b733d02c2f4dd46 (diff)
crippled filesystem support, probing and initial support
git annex init probes for crippled filesystems, and sets direct mode, as well as `annex.crippledfilesystem`. Avoid manipulating permissions of files on crippled filesystems. That would likely cause an exception to be thrown. Very basic support in Command.Add for cripped filesystems; avoids the lock down entirely since doing it needs both permissions and hard links. Will make this better soon.
Diffstat (limited to 'Init.hs')
-rw-r--r--Init.hs27
1 files changed, 27 insertions, 0 deletions
diff --git a/Init.hs b/Init.hs
index a6f4fa935..77b36b6dd 100644
--- a/Init.hs
+++ b/Init.hs
@@ -22,6 +22,8 @@ import Annex.Version
import Annex.UUID
import Utility.UserInfo
import Utility.Shell
+import Utility.FileMode
+import Config
genDescription :: Maybe String -> Annex String
genDescription (Just d) = return d
@@ -35,6 +37,7 @@ genDescription Nothing = do
initialize :: Maybe String -> Annex ()
initialize mdescription = do
prepUUID
+ probeCrippledFileSystem
Annex.Branch.create
setVersion
gitPreCommitHookWrite
@@ -98,3 +101,27 @@ preCommitScript = unlines
, "# automatically configured by git-annex"
, "git annex pre-commit ."
]
+
+probeCrippledFileSystem :: Annex ()
+probeCrippledFileSystem = do
+ tmp <- fromRepo gitAnnexTmpDir
+ let f = tmp </> "init-probe"
+ 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
+ liftIO $ removeFile f
+ where
+ probe f = catchBoolIO $ do
+ let f2 = f ++ "2"
+ nukeFile f2
+ createLink f f2
+ nukeFile f2
+ createSymbolicLink f f2
+ nukeFile f2
+ preventWrite f
+ allowWrite f
+ return True