assistant: update export db after mergeing git-annex branch changes

Needed so that the assistant can download from exports.
updateExportTreeFromLog is normally only run one time, but needs to be
run repeatedly during the lifetime of the assistant.

This commit was sponsored by Ethan Aubin on Patreon.
This commit is contained in:
Joey Hess 2017-09-20 16:34:29 -04:00
parent 129418615b
commit 82a2d19af1
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
2 changed files with 12 additions and 1 deletions

View file

@ -35,6 +35,7 @@ import Assistant.TransferQueue
import Assistant.RepoProblem
import Assistant.Commits
import Types.Transfer
import Database.Export
import Data.Time.Clock
import qualified Data.Map as M
@ -218,6 +219,8 @@ manualPull currentbranch remotes = do
forM_ normalremotes $ \r ->
liftAnnex $ Command.Sync.mergeRemote r
currentbranch Command.Sync.mergeConfig def
when haddiverged $
updateExportTreeFromLogAll
return (catMaybes failed, haddiverged)
where
wantpull gc = remoteAnnexPull gc
@ -264,3 +267,9 @@ changeSyncFlag r enabled = do
void Remote.remoteListRefresh
where
key = Config.remoteConfig (Remote.repo r) "sync"
updateExportTreeFromLogAll :: Assistant ()
updateExportTreeFromLogAll = do
rs <- exportRemotes <$> getDaemonStatus
forM_ rs $ \r -> liftAnnex $
openDb (Remote.uuid r) >>= updateExportTreeFromLog

View file

@ -10,6 +10,7 @@ module Assistant.Threads.Merger where
import Assistant.Common
import Assistant.TransferQueue
import Assistant.BranchChange
import Assistant.Sync
import Utility.DirWatcher
import Utility.DirWatcher.Types
import qualified Annex.Branch
@ -62,7 +63,8 @@ onChange file
| isAnnexBranch file = do
branchChanged
diverged <- liftAnnex Annex.Branch.forceUpdate
when diverged $
when diverged $ do
updateExportTreeFromLogAll
queueDeferredDownloads "retrying deferred download" Later
| otherwise = mergecurrent
where