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.
This commit is contained in:
Joey Hess 2013-02-14 14:10:36 -04:00
parent 35b7b1a406
commit 47477b2807
15 changed files with 122 additions and 52 deletions

View file

@ -183,12 +183,14 @@ storeHelper d chunksize key storer = check <&&> go
void $ tryIO $ removeDirectoryRecursive dest -- or not exist
createDirectoryIfMissing True (parentDir dest)
renameDirectory tmp dest
mapM_ preventWrite =<< dirContents dest
preventWrite dest
-- may fail on some filesystems
void $ tryIO $ do
mapM_ preventWrite =<< dirContents dest
preventWrite dest
recorder f s = do
void $ tryIO $ allowWrite f
writeFile f s
preventWrite f
void $ tryIO $ preventWrite f
retrieve :: FilePath -> ChunkSize -> Key -> AssociatedFile -> FilePath -> Annex Bool
retrieve d chunksize k _ f = metered Nothing k $ \meterupdate ->
@ -215,10 +217,11 @@ retrieveCheap d _ k f = liftIO $ withStoredFiles Nothing d k go
go _files = return False
remove :: FilePath -> Key -> Annex Bool
remove d k = liftIO $ catchBoolIO $ do
allowWrite dir
removeDirectoryRecursive dir
return True
remove d k = liftIO $ do
void $ tryIO $ allowWrite dir
catchBoolIO $ do
removeDirectoryRecursive dir
return True
where
dir = storeDir d k