summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Assistant/Threads/Committer.hs32
-rw-r--r--Command/Add.hs14
2 files changed, 24 insertions, 22 deletions
diff --git a/Assistant/Threads/Committer.hs b/Assistant/Threads/Committer.hs
index e77c55dfd..f1e26f9aa 100644
--- a/Assistant/Threads/Committer.hs
+++ b/Assistant/Threads/Committer.hs
@@ -266,14 +266,13 @@ handleAdds delayadd cs = returnWhen (null incomplete) $ do
Just cache ->
case M.lookup (inodeCacheToKey ct cache) m of
Nothing -> add c
- Just k -> fastadd c k cache
+ Just k -> fastadd c k
- fastadd :: Change -> Key -> InodeCache -> Assistant (Maybe Change)
- fastadd change key cache = do
- -- TODO do fast method
- debug ["rename detected", show change, show key, show cache]
- add change
- --return $ Just $ finishedChange change key
+ fastadd :: Change -> Key -> Assistant (Maybe Change)
+ fastadd change key = do
+ let source = keySource change
+ liftAnnex $ Command.Add.finishIngestDirect key source
+ done change (keyFilename source) key
removedKeysMap :: InodeComparisonType -> [Change] -> Annex (M.Map InodeCacheKey Key)
removedKeysMap ct l = do
@@ -291,16 +290,15 @@ handleAdds delayadd cs = returnWhen (null incomplete) $ do
liftAnnex showEndFail
return Nothing
- done change file key = do
- liftAnnex $ do
- logStatus key InfoPresent
- link <- ifM isDirect
- ( calcGitLink file key
- , Command.Add.link file key True
- )
- whenM (pure DirWatcher.eventsCoalesce <||> isDirect) $ do
- stageSymlink file =<< hashSymlink link
- showEndOk
+ done change file key = liftAnnex $ do
+ logStatus key InfoPresent
+ link <- ifM isDirect
+ ( calcGitLink file key
+ , Command.Add.link file key True
+ )
+ whenM (pure DirWatcher.eventsCoalesce <||> isDirect) $ do
+ stageSymlink file =<< hashSymlink link
+ showEndOk
return $ Just $ finishedChange change key
{- Check that the keysource's keyFilename still exists,
diff --git a/Command/Add.hs b/Command/Add.hs
index 7100006c6..343ffbe95 100644
--- a/Command/Add.hs
+++ b/Command/Add.hs
@@ -125,11 +125,7 @@ ingest (Just source) = do
godirect (Just (key, _)) (Just cache) = do
writeInodeCache key cache
- void $ addAssociatedFile key $ keyFilename source
- unlessM crippledFileSystem $
- liftIO $ allowWrite $ keyFilename source
- when (contentLocation source /= keyFilename source) $
- liftIO $ nukeFile $ contentLocation source
+ finishIngestDirect key source
return $ Just key
godirect _ _ = failure
@@ -138,6 +134,14 @@ ingest (Just source) = do
liftIO $ nukeFile $ contentLocation source
return Nothing
+finishIngestDirect :: Key -> KeySource -> Annex ()
+finishIngestDirect key source = do
+ void $ addAssociatedFile key $ keyFilename source
+ unlessM crippledFileSystem $
+ liftIO $ allowWrite $ keyFilename source
+ when (contentLocation source /= keyFilename source) $
+ liftIO $ nukeFile $ contentLocation source
+
perform :: FilePath -> CommandPerform
perform file =
maybe stop (\key -> next $ cleanup file key True)