add exporter thread to assistant
This is similar to the pusher thread, but a separate thread because git pushes can be done in parallel with exports, and updating a big export should not prevent other git pushes going out in the meantime. The exportThread only runs at most every 30 seconds, since updating an export is more expensive than pushing. This may need to be tuned. Added a separate channel for export commits; the committer records a commit in that channel. Also, reconnectRemotes records a dummy commit, to make the exporter thread wake up and make sure all exports are up-to-date. So, connecting a drive with a directory special remote export will immediately update it, and getting online will automatically update S3 and WebDAV exports. The transfer queue is not involved in exports. Instead, failed exports are retried much like failed pushes. This commit was sponsored by Ewen McNeill.
This commit is contained in:
parent
46d19648ee
commit
d71c65ca0a
13 changed files with 124 additions and 22 deletions
|
@ -33,6 +33,7 @@ import Assistant.Threads.Watcher (watchThread, WatcherControl(..))
|
|||
import Assistant.TransferSlots
|
||||
import Assistant.TransferQueue
|
||||
import Assistant.RepoProblem
|
||||
import Assistant.Commits
|
||||
import Types.Transfer
|
||||
|
||||
import Data.Time.Clock
|
||||
|
@ -48,10 +49,10 @@ import Control.Concurrent
|
|||
- it's sufficient to requeue failed transfers.
|
||||
-
|
||||
- Also handles signaling any connectRemoteNotifiers, after the syncing is
|
||||
- done.
|
||||
- done, and records an export commit to make any exports be updated.
|
||||
-}
|
||||
reconnectRemotes :: [Remote] -> Assistant ()
|
||||
reconnectRemotes [] = noop
|
||||
reconnectRemotes [] = recordExportCommit
|
||||
reconnectRemotes rs = void $ do
|
||||
rs' <- liftIO $ filterM (Remote.checkAvailable True) rs
|
||||
unless (null rs') $ do
|
||||
|
@ -60,6 +61,7 @@ reconnectRemotes rs = void $ do
|
|||
whenM (liftIO $ Remote.checkAvailable False r) $
|
||||
repoHasProblem (Remote.uuid r) (syncRemote r)
|
||||
mapM_ signal $ filter (`notElem` failedrs) rs'
|
||||
recordExportCommit
|
||||
where
|
||||
gitremotes = filter (notspecialremote . Remote.repo) rs
|
||||
(_xmppremotes, nonxmppremotes) = partition Remote.isXMPPRemote rs
|
||||
|
@ -143,9 +145,11 @@ pushToRemotes' now remotes = do
|
|||
then retry currbranch g u failed
|
||||
else fallback branch g u failed
|
||||
|
||||
updatemap succeeded failed = changeFailedPushMap $ \m ->
|
||||
M.union (makemap failed) $
|
||||
M.difference m (makemap succeeded)
|
||||
updatemap succeeded failed = do
|
||||
v <- getAssistant failedPushMap
|
||||
changeFailedPushMap v $ \m ->
|
||||
M.union (makemap failed) $
|
||||
M.difference m (makemap succeeded)
|
||||
makemap l = M.fromList $ zip l (repeat now)
|
||||
|
||||
retry currbranch g u rs = do
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue