better variable name
This commit is contained in:
parent
b2d266267f
commit
6ea6a2e71c
9 changed files with 22 additions and 23 deletions
|
@ -41,8 +41,8 @@ data DaemonStatus = DaemonStatus
|
|||
-- Messages to display to the user.
|
||||
, alertMap :: AlertMap
|
||||
, lastAlertId :: AlertId
|
||||
-- Ordered list of remotes to talk to.
|
||||
, knownRemotes :: [Remote]
|
||||
-- Ordered list of remotes to sync with.
|
||||
, syncRemotes :: [Remote]
|
||||
-- Pairing request that is in progress.
|
||||
, pairingInProgress :: Maybe PairingInProgress
|
||||
-- Broadcasts notifications about all changes to the DaemonStatus
|
||||
|
@ -89,21 +89,20 @@ modifyDaemonStatus dstatus a = do
|
|||
return b
|
||||
|
||||
{- Syncable remotes ordered by cost. -}
|
||||
calcKnownRemotes :: Annex [Remote]
|
||||
calcKnownRemotes = do
|
||||
calcSyncRemotes :: Annex [Remote]
|
||||
calcSyncRemotes = do
|
||||
rs <- filterM (repoSyncable . Remote.repo) =<<
|
||||
concat . Remote.byCost <$> Remote.enabledRemoteList
|
||||
alive <- snd <$> trustPartition DeadTrusted (map Remote.uuid rs)
|
||||
let good r = Remote.uuid r `elem` alive
|
||||
return $ filter good rs
|
||||
|
||||
{- Updates the cached ordered list of remotes from the list in Annex
|
||||
- state. -}
|
||||
updateKnownRemotes :: DaemonStatusHandle -> Annex ()
|
||||
updateKnownRemotes dstatus = do
|
||||
remotes <- calcKnownRemotes
|
||||
{- Updates the sycRemotes list from the list of all remotes in Annex state. -}
|
||||
updateSyncRemotes :: DaemonStatusHandle -> Annex ()
|
||||
updateSyncRemotes dstatus = do
|
||||
remotes <- calcSyncRemotes
|
||||
liftIO $ modifyDaemonStatus_ dstatus $
|
||||
\s -> s { knownRemotes = remotes }
|
||||
\s -> s { syncRemotes = remotes }
|
||||
|
||||
{- Load any previous daemon status file, and store it in a MVar for this
|
||||
- process to use as its DaemonStatus. Also gets current transfer status. -}
|
||||
|
@ -113,12 +112,12 @@ startDaemonStatus = do
|
|||
status <- liftIO $
|
||||
flip catchDefaultIO (readDaemonStatusFile file) =<< newDaemonStatus
|
||||
transfers <- M.fromList <$> getTransfers
|
||||
remotes <- calcKnownRemotes
|
||||
remotes <- calcSyncRemotes
|
||||
liftIO $ atomically $ newTMVar status
|
||||
{ scanComplete = False
|
||||
, sanityCheckRunning = False
|
||||
, currentTransfers = transfers
|
||||
, knownRemotes = remotes
|
||||
, syncRemotes = remotes
|
||||
}
|
||||
|
||||
{- Don't just dump out the structure, because it will change over time,
|
||||
|
|
|
@ -156,5 +156,5 @@ manualPull st currentbranch remotes = do
|
|||
{- Start syncing a newly added remote, using a background thread. -}
|
||||
syncNewRemote :: ThreadState -> DaemonStatusHandle -> ScanRemoteMap -> Remote -> IO ()
|
||||
syncNewRemote st dstatus scanremotes remote = do
|
||||
runThreadState st $ updateKnownRemotes dstatus
|
||||
runThreadState st $ updateSyncRemotes dstatus
|
||||
void $ forkIO $ reconnectRemotes "SyncRemote" st dstatus scanremotes [remote]
|
||||
|
|
|
@ -174,7 +174,7 @@ remotesUnder st dstatus dir = runThreadState st $ do
|
|||
let (waschanged, rs') = unzip pairs
|
||||
when (any id waschanged) $ do
|
||||
Annex.changeState $ \s -> s { Annex.remotes = rs' }
|
||||
updateKnownRemotes dstatus
|
||||
updateSyncRemotes dstatus
|
||||
return $ map snd $ filter fst pairs
|
||||
where
|
||||
checkremote repotop r = case Remote.localpath r of
|
||||
|
|
|
@ -52,7 +52,7 @@ pushThread st dstatus commitchan pushmap = thread $ runEvery (Seconds 2) $ do
|
|||
now <- getCurrentTime
|
||||
if shouldPush now commits
|
||||
then do
|
||||
remotes <- filter pushable . knownRemotes
|
||||
remotes <- filter pushable . syncRemotes
|
||||
<$> getDaemonStatus dstatus
|
||||
unless (null remotes) $
|
||||
void $ alertWhile dstatus (pushAlert remotes) $
|
||||
|
|
|
@ -61,7 +61,7 @@ transferScannerThread st dstatus scanremotes transferqueue = thread $ do
|
|||
- lost.
|
||||
-}
|
||||
startupScan = addScanRemotes scanremotes True
|
||||
=<< knownRemotes <$> getDaemonStatus dstatus
|
||||
=<< syncRemotes <$> getDaemonStatus dstatus
|
||||
|
||||
{- This is a cheap scan for failed transfers involving a remote. -}
|
||||
failedTransferScan :: ThreadState -> DaemonStatusHandle -> TransferQueue -> Remote -> IO ()
|
||||
|
@ -117,8 +117,8 @@ expensiveScan st dstatus transferqueue rs = unless onlyweb $ do
|
|||
{- Queue transfers from any known remote. The known
|
||||
- remotes may have changed since this scan began. -}
|
||||
let use a = do
|
||||
knownrs <- liftIO $ knownRemotes <$> getDaemonStatus dstatus
|
||||
return $ catMaybes $ map (a key locs) knownrs
|
||||
syncrs <- liftIO $ syncRemotes <$> getDaemonStatus dstatus
|
||||
return $ catMaybes $ map (a key locs) syncrs
|
||||
ifM (inAnnex key)
|
||||
( filterM (wantSend (Just f) . Remote.uuid . fst)
|
||||
=<< use (check Upload False)
|
||||
|
|
|
@ -67,7 +67,7 @@ onAdd st dstatus _ file _ = case parseTransferFile file of
|
|||
[ "transfer starting:"
|
||||
, show t
|
||||
]
|
||||
r <- headMaybe . filter (sameuuid t) . knownRemotes
|
||||
r <- headMaybe . filter (sameuuid t) . syncRemotes
|
||||
<$> getDaemonStatus dstatus
|
||||
updateTransferInfo dstatus t info
|
||||
{ transferRemote = r }
|
||||
|
|
|
@ -71,7 +71,7 @@ queueTransfersMatching matching schedule q dstatus k f direction
|
|||
where
|
||||
go = do
|
||||
rs <- sufficientremotes
|
||||
=<< knownRemotes <$> liftIO (getDaemonStatus dstatus)
|
||||
=<< syncRemotes <$> liftIO (getDaemonStatus dstatus)
|
||||
let matchingrs = filter (matching . Remote.uuid) rs
|
||||
if null matchingrs
|
||||
then defer
|
||||
|
@ -104,7 +104,7 @@ queueTransfersMatching matching schedule q dstatus k f direction
|
|||
- any others in the list to try again later. -}
|
||||
queueDeferredDownloads :: Schedule -> TransferQueue -> DaemonStatusHandle -> Annex ()
|
||||
queueDeferredDownloads schedule q dstatus = do
|
||||
rs <- knownRemotes <$> liftIO (getDaemonStatus dstatus)
|
||||
rs <- syncRemotes <$> liftIO (getDaemonStatus dstatus)
|
||||
l <- liftIO $ atomically $ swapTVar (deferreddownloads q) []
|
||||
left <- filterM (queue rs) l
|
||||
unless (null left) $
|
||||
|
|
|
@ -99,7 +99,7 @@ repoList onlyconfigured includehere
|
|||
| otherwise = list =<< (++) <$> configured <*> rest
|
||||
where
|
||||
configured = do
|
||||
rs <- filter (not . Remote.readonly) . knownRemotes <$>
|
||||
rs <- filter (not . Remote.readonly) . syncRemotes <$>
|
||||
(liftIO . getDaemonStatus =<< daemonStatus <$> getYesod)
|
||||
runAnnex [] $ do
|
||||
u <- getUUID
|
||||
|
|
|
@ -40,7 +40,7 @@ changeSyncable (Just r) False = do
|
|||
webapp <- getYesod
|
||||
let dstatus = daemonStatus webapp
|
||||
let st = fromJust $ threadState webapp
|
||||
liftIO $ runThreadState st $ updateKnownRemotes dstatus
|
||||
liftIO $ runThreadState st $ updateSyncRemotes dstatus
|
||||
{- Stop all transfers to or from this remote.
|
||||
- XXX Can't stop any ongoing scan, or git syncs. -}
|
||||
void $ liftIO $ dequeueTransfers (transferQueue webapp) dstatus tofrom
|
||||
|
|
Loading…
Add table
Reference in a new issue