convert checkAvailable to use availability rather than localpath

Every remote that sets localpath also implements an availability that
reutrns Unavailable when a local directory is not available.

This makes external remotes, and others that get support for
availability Unavailable to be used by checkAvailable. (Which is only
used by the assistant.)

Had to keep localpath though, since other parts of the assistant use it
to eg, sync with a remote when a removable drive is plugged in.

Sponsored-by: Jack Hill on Patreon
This commit is contained in:
Joey Hess 2023-08-16 15:57:30 -04:00
parent 7aac60769a
commit 83056e7b53
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
5 changed files with 11 additions and 8 deletions

View file

@ -59,11 +59,11 @@ import Control.Concurrent.Async
reconnectRemotes :: [Remote] -> Assistant ()
reconnectRemotes [] = recordExportCommit
reconnectRemotes rs = void $ do
rs' <- liftIO $ filterM (Remote.checkAvailable True) rs
rs' <- liftAnnex $ filterM (Remote.checkAvailable True) rs
unless (null rs') $ do
failedrs <- syncAction rs' (const go)
forM_ failedrs $ \r ->
whenM (liftIO $ Remote.checkAvailable False r) $
whenM (liftAnnex $ Remote.checkAvailable False r) $
repoHasProblem (Remote.uuid r) (syncRemote r)
mapM_ signal $ filter (`notElem` failedrs) rs'
recordExportCommit