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