diff options
Diffstat (limited to 'Command')
-rw-r--r-- | Command/Add.hs | 34 | ||||
-rw-r--r-- | Command/AddUrl.hs | 11 |
2 files changed, 14 insertions, 31 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 diff --git a/Command/AddUrl.hs b/Command/AddUrl.hs index 333ca494d..0370a2fc9 100644 --- a/Command/AddUrl.hs +++ b/Command/AddUrl.hs @@ -12,7 +12,6 @@ import Network.URI import Command import Backend import qualified Annex -import qualified Annex.Queue import qualified Annex.Url as Url import qualified Backend.URL import qualified Remote @@ -24,8 +23,6 @@ import Annex.UUID import Logs.Web import Types.KeySource import Types.UrlContents -import Config -import Annex.Content.Direct import Annex.FileMatcher import Logs.Location import Utility.Metered @@ -363,13 +360,7 @@ cleanup u url file key mtmp = case mtmp of when (isJust mtmp) $ logStatus key InfoPresent setUrlPresent u key url - addLink file key Nothing - whenM isDirect $ do - void $ addAssociatedFile key file - {- For moveAnnex to work in direct mode, the symlink - - must already exist, so flush the queue. -} - Annex.Queue.flush - maybe noop (moveAnnex key) mtmp + addAnnexedFile file key mtmp nodownload :: URLString -> Url.UrlInfo -> FilePath -> Annex (Maybe Key) nodownload url urlinfo file |