This commit is contained in:
Joey Hess 2012-08-22 14:32:17 -04:00
parent 5a68acb521
commit 68659f4998
5 changed files with 108 additions and 105 deletions

View file

@ -14,21 +14,17 @@ import Assistant.Common
import Assistant.ThreadedMonad
import Assistant.DaemonStatus
import Assistant.ScanRemotes
import Assistant.Threads.Pusher (pushToRemotes)
import Assistant.Alert
import Assistant.Sync
import qualified Annex
import qualified Git
import Utility.ThreadScheduler
import Utility.Mounts
import Remote.List
import qualified Types.Remote as Remote
import Assistant.Threads.Merger
import qualified Git.Branch
import Control.Concurrent
import qualified Control.Exception as E
import qualified Data.Set as S
import Data.Time.Clock
#if WITH_DBUS
import Utility.DBus
@ -146,23 +142,9 @@ handleMounts st dstatus scanremotes wasmounted nowmounted =
handleMount :: ThreadState -> DaemonStatusHandle -> ScanRemoteMap -> FilePath -> IO ()
handleMount st dstatus scanremotes dir = do
debug thisThread ["detected mount of", dir]
rs <- remotesUnder st dstatus dir
unless (null rs) $ do
let nonspecial = filter (Git.repoIsLocal . Remote.repo) rs
unless (null nonspecial) $ do
void $ alertWhile dstatus (syncAlert nonspecial) $ do
debug thisThread ["syncing with", show nonspecial]
sync nonspecial =<< runThreadState st (inRepo Git.Branch.current)
addScanRemotes scanremotes nonspecial
where
sync rs (Just branch) = do
runThreadState st $ manualPull (Just branch) rs
now <- getCurrentTime
pushToRemotes thisThread now st Nothing rs
{- No local branch exists yet, but we can try pulling. -}
sync rs Nothing = do
runThreadState st $ manualPull Nothing rs
return True
syncRemotes thisThread st dstatus scanremotes
=<< filter (Git.repoIsLocal . Remote.repo)
<$> remotesUnder st dstatus dir
{- Finds remotes located underneath the mount point.
-