diff options
Diffstat (limited to 'Command')
-rw-r--r-- | Command/Add.hs | 37 | ||||
-rw-r--r-- | Command/Fsck.hs | 3 |
2 files changed, 24 insertions, 16 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 diff --git a/Command/Fsck.hs b/Command/Fsck.hs index 8f33493b5..666245517 100644 --- a/Command/Fsck.hs +++ b/Command/Fsck.hs @@ -203,7 +203,8 @@ fixLink key file = do showNote "fixing content location" dir <- liftIO $ parentDir <$> absPath file let content = absPathFrom dir have - liftIO $ allowWrite (parentDir content) + unlessM crippledFileSystem $ + liftIO $ allowWrite (parentDir content) moveAnnex key content showNote "fixing link" |