diff options
author | Joey Hess <joey@kitenet.net> | 2013-02-14 14:10:36 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2013-02-14 14:15:26 -0400 |
commit | 177245deb6ee3271eb44d77c2b0cd722755b2c3f (patch) | |
tree | 876c4844937c831470192d367123f581fb6cc3d8 /Command/Add.hs | |
parent | 4e2d50d2e4c9b4d3487c24042b733d02c2f4dd46 (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 'Command/Add.hs')
-rw-r--r-- | Command/Add.hs | 37 |
1 files changed, 22 insertions, 15 deletions
diff --git a/Command/Add.hs b/Command/Add.hs index bfab33099..f6b43034c 100644 --- a/Command/Add.hs +++ b/Command/Add.hs @@ -67,18 +67,22 @@ start file = ifAnnexed file fixup add - Lockdown can fail if a file gets deleted, and Nothing will be returned. -} lockDown :: FilePath -> Annex (Maybe KeySource) -lockDown file = do - tmp <- fromRepo gitAnnexTmpDir - createAnnexDirectory tmp - liftIO $ catchMaybeIO $ do - preventWrite file - (tmpfile, h) <- openTempFile tmp (takeFileName file) - hClose h - nukeFile tmpfile - createLink file tmpfile - return $ KeySource { keyFilename = file , contentLocation = tmpfile } - -{- Moves a locked down file into the annex. +lockDown file = ifM (crippledFileSystem) + ( return $ Just $ + KeySource { keyFilename = file, contentLocation = file } + , do + tmp <- fromRepo gitAnnexTmpDir + createAnnexDirectory tmp + liftIO $ catchMaybeIO $ do + preventWrite file + (tmpfile, h) <- openTempFile tmp (takeFileName file) + hClose h + nukeFile tmpfile + createLink file tmpfile + return $ KeySource { keyFilename = file , contentLocation = tmpfile } + ) + +{- Ingests a locked down file into the annex. - - In direct mode, leaves the file alone, and just updates bookkeeping - information. @@ -107,15 +111,18 @@ ingest (Just source) = do ( do writeCache key cache void $ addAssociatedFile key $ keyFilename source - liftIO $ allowWrite $ keyFilename source - liftIO $ nukeFile $ contentLocation source + unlessM crippledFileSystem $ + liftIO $ allowWrite $ keyFilename source + when (contentLocation source /= keyFilename source) $ + liftIO $ nukeFile $ contentLocation source return $ Just key , failure ) godirect _ _ = failure failure = do - liftIO $ nukeFile $ contentLocation source + when (contentLocation source /= keyFilename source) $ + liftIO $ nukeFile $ contentLocation source return Nothing perform :: FilePath -> CommandPerform |