summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Assistant/Alert.hs2
-rw-r--r--Assistant/Threads/Committer.hs47
-rw-r--r--Messages.hs1
3 files changed, 32 insertions, 18 deletions
diff --git a/Assistant/Alert.hs b/Assistant/Alert.hs
index f412e6232..da22d6031 100644
--- a/Assistant/Alert.hs
+++ b/Assistant/Alert.hs
@@ -233,7 +233,7 @@ fileAlert msg file = (activityAlert Nothing [f])
render fs = tenseWords $ msg : fs
combiner new old = take 10 $ new ++ old
-addFileAlert :: FilePath -> Alert
+addFileAlert :: String -> Alert
addFileAlert = fileAlert (Tensed "Adding" "Added")
{- This is only used as a success alert after a transfer, not during it. -}
diff --git a/Assistant/Threads/Committer.hs b/Assistant/Threads/Committer.hs
index 04f94143b..8fe48bfb7 100644
--- a/Assistant/Threads/Committer.hs
+++ b/Assistant/Threads/Committer.hs
@@ -231,9 +231,10 @@ handleAdds delayadd cs = returnWhen (null incomplete) $ do
refillChanges postponed
returnWhen (null toadd) $ do
- added <- catMaybes <$> if direct
- then adddirect toadd
- else forM toadd add
+ added <- addaction toadd $
+ catMaybes <$> if direct
+ then adddirect toadd
+ else forM toadd add
if DirWatcher.eventsCoalesce || null added || direct
then return $ added ++ otherchanges
else do
@@ -256,19 +257,13 @@ handleAdds delayadd cs = returnWhen (null incomplete) $ do
| otherwise = a
add :: Change -> Assistant (Maybe Change)
- add change@(InProcessAddChange { keySource = ks }) =
- alertWhile' (addFileAlert $ keyFilename ks) $
- liftM ret $ catchMaybeIO <~> do
- sanitycheck ks $ do
- key <- liftAnnex $ do
- showStart "add" $ keyFilename ks
- Command.Add.ingest $ Just ks
- maybe (failedingest change) (done change $ keyFilename ks) key
- where
- {- Add errors tend to be transient and will be automatically
- - dealt with, so don't pass to the alert code. -}
- ret (Just j@(Just _)) = (True, j)
- ret _ = (True, Nothing)
+ add change@(InProcessAddChange { keySource = ks }) =
+ catchDefaultIO Nothing <~> do
+ sanitycheck ks $ do
+ key <- liftAnnex $ do
+ showStart "add" $ keyFilename ks
+ Command.Add.ingest $ Just ks
+ maybe (failedingest change) (done change $ keyFilename ks) key
add _ = return Nothing
{- In direct mode, avoid overhead of re-injesting a renamed
@@ -336,6 +331,26 @@ handleAdds delayadd cs = returnWhen (null incomplete) $ do
void $ liftIO $ tryIO $ removeFile $ contentLocation keysource
return Nothing
+ {- Shown an alert while performing an action to add a file or
+ - files. When only one file is added, its name is shown
+ - in the alert. When it's a batch add, the number of files added
+ - is shown.
+ -
+ - Add errors tend to be transient and will be
+ - automatically dealt with, so the alert is always told
+ - the add succeeded.
+ -}
+ addaction [] a = a
+ addaction toadd a = alertWhile' (addFileAlert msg) $
+ (,)
+ <$> pure True
+ <*> a
+ where
+ msg = case toadd of
+ (InProcessAddChange { keySource = ks }:[]) ->
+ keyFilename ks
+ _ -> show (length toadd) ++ " files"
+
{- Files can Either be Right to be added now,
- or are unsafe, and must be Left for later.
-
diff --git a/Messages.hs b/Messages.hs
index 68bd92673..b2fcba881 100644
--- a/Messages.hs
+++ b/Messages.hs
@@ -31,7 +31,6 @@ module Messages (
showCustom,
showHeader,
showRaw,
-
setupConsole
) where