diff options
author | 2016-02-16 14:43:43 -0400 | |
---|---|---|
committer | 2016-02-16 14:43:43 -0400 | |
commit | c11633a52dbdcc187f5afcef50776fa41c7327ce (patch) | |
tree | 1de24f154cb953f9ce78c68315bc046d48f838c7 /Command/Add.hs | |
parent | 3776dee0a33fe3fe0cd1aceb14b5c2d0511d6c05 (diff) |
annex.addunlocked
* add, addurl, import, importfeed: When in a v6 repository on a crippled
filesystem, add files unlocked.
* annex.addunlocked: New configuration setting, makes files always be
added unlocked. (v6 only)
Diffstat (limited to 'Command/Add.hs')
-rw-r--r-- | Command/Add.hs | 34 |
1 files changed, 13 insertions, 21 deletions
diff --git a/Command/Add.hs b/Command/Add.hs index 7a1150d10..194e34de0 100644 --- a/Command/Add.hs +++ b/Command/Add.hs @@ -12,12 +12,10 @@ import Annex.Ingest import Logs.Location import Annex.Content import Annex.Content.Direct -import Annex.Link import qualified Annex import qualified Annex.Queue import qualified Database.Keys import Config -import Utility.InodeCache import Annex.FileMatcher import Annex.Version @@ -99,48 +97,42 @@ start file = ifAnnexed file addpresent add ( do ms <- liftIO $ catchMaybeIO $ getSymbolicLinkStatus file case ms of - Just s | isSymbolicLink s -> fixup key + Just s | isSymbolicLink s -> fixuplink key _ -> ifM (sameInodeCache file =<< Database.Keys.getInodeCaches key) ( stop, add ) , ifM isDirect ( do ms <- liftIO $ catchMaybeIO $ getSymbolicLinkStatus file case ms of - Just s | isSymbolicLink s -> fixup key + Just s | isSymbolicLink s -> fixuplink key _ -> ifM (goodContent key file) ( stop , add ) - , fixup key + , fixuplink key ) ) - fixup key = do + fixuplink key = do -- the annexed symlink is present but not yet added to git showStart "add" file liftIO $ removeFile file - whenM isDirect $ - void $ addAssociatedFile key file - next $ next $ cleanup file key Nothing =<< inAnnex key + next $ next $ do + addLink file key Nothing + cleanup key =<< inAnnex key perform :: FilePath -> CommandPerform perform file = do - lockingfile <- not <$> isDirect + lockingfile <- not <$> addUnlocked let cfg = LockDownConfig { lockingFile = lockingfile , hardlinkFileTmp = True } - lockDown cfg file >>= ingest >>= go + lockDown cfg file >>= ingestAdd >>= finish where - go (Just key, cache) = next $ cleanup file key cache True - go (Nothing, _) = stop + finish (Just key) = next $ cleanup key True + finish Nothing = stop -cleanup :: FilePath -> Key -> Maybe InodeCache -> Bool -> CommandCleanup -cleanup file key mcache hascontent = do +cleanup :: Key -> Bool -> CommandCleanup +cleanup key hascontent = do maybeShowJSON [("key", key2file key)] - ifM (isDirect <&&> pure hascontent) - ( do - l <- calcRepo $ gitAnnexLink file key - stageSymlink file =<< hashSymlink l - , addLink file key mcache - ) when hascontent $ logStatus key InfoPresent return True |