show one alert when bulk adding files
Turns out that a lot of the time spent in a bulk add was just updating the add alert to rotate through each file that was added. Showing one alert makes for a significant speedup. Also, when the webapp is open, this makes it take quite a lot less cpu during bulk adds. Also, it lets the user know when a bulk add happened, which is sorta nice..
This commit is contained in:
parent
6e5c7520ff
commit
a929e6641a
3 changed files with 32 additions and 18 deletions
|
@ -233,7 +233,7 @@ fileAlert msg file = (activityAlert Nothing [f])
|
||||||
render fs = tenseWords $ msg : fs
|
render fs = tenseWords $ msg : fs
|
||||||
combiner new old = take 10 $ new ++ old
|
combiner new old = take 10 $ new ++ old
|
||||||
|
|
||||||
addFileAlert :: FilePath -> Alert
|
addFileAlert :: String -> Alert
|
||||||
addFileAlert = fileAlert (Tensed "Adding" "Added")
|
addFileAlert = fileAlert (Tensed "Adding" "Added")
|
||||||
|
|
||||||
{- This is only used as a success alert after a transfer, not during it. -}
|
{- This is only used as a success alert after a transfer, not during it. -}
|
||||||
|
|
|
@ -231,9 +231,10 @@ handleAdds delayadd cs = returnWhen (null incomplete) $ do
|
||||||
refillChanges postponed
|
refillChanges postponed
|
||||||
|
|
||||||
returnWhen (null toadd) $ do
|
returnWhen (null toadd) $ do
|
||||||
added <- catMaybes <$> if direct
|
added <- addaction toadd $
|
||||||
then adddirect toadd
|
catMaybes <$> if direct
|
||||||
else forM toadd add
|
then adddirect toadd
|
||||||
|
else forM toadd add
|
||||||
if DirWatcher.eventsCoalesce || null added || direct
|
if DirWatcher.eventsCoalesce || null added || direct
|
||||||
then return $ added ++ otherchanges
|
then return $ added ++ otherchanges
|
||||||
else do
|
else do
|
||||||
|
@ -256,19 +257,13 @@ handleAdds delayadd cs = returnWhen (null incomplete) $ do
|
||||||
| otherwise = a
|
| otherwise = a
|
||||||
|
|
||||||
add :: Change -> Assistant (Maybe Change)
|
add :: Change -> Assistant (Maybe Change)
|
||||||
add change@(InProcessAddChange { keySource = ks }) =
|
add change@(InProcessAddChange { keySource = ks }) =
|
||||||
alertWhile' (addFileAlert $ keyFilename ks) $
|
catchDefaultIO Nothing <~> do
|
||||||
liftM ret $ catchMaybeIO <~> do
|
sanitycheck ks $ do
|
||||||
sanitycheck ks $ do
|
key <- liftAnnex $ do
|
||||||
key <- liftAnnex $ do
|
showStart "add" $ keyFilename ks
|
||||||
showStart "add" $ keyFilename ks
|
Command.Add.ingest $ Just ks
|
||||||
Command.Add.ingest $ Just ks
|
maybe (failedingest change) (done change $ keyFilename ks) key
|
||||||
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 _ = return Nothing
|
add _ = return Nothing
|
||||||
|
|
||||||
{- In direct mode, avoid overhead of re-injesting a renamed
|
{- 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
|
void $ liftIO $ tryIO $ removeFile $ contentLocation keysource
|
||||||
return Nothing
|
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,
|
{- Files can Either be Right to be added now,
|
||||||
- or are unsafe, and must be Left for later.
|
- or are unsafe, and must be Left for later.
|
||||||
-
|
-
|
||||||
|
|
|
@ -31,7 +31,6 @@ module Messages (
|
||||||
showCustom,
|
showCustom,
|
||||||
showHeader,
|
showHeader,
|
||||||
showRaw,
|
showRaw,
|
||||||
|
|
||||||
setupConsole
|
setupConsole
|
||||||
) where
|
) where
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue