let Remote.availability return Unavilable
This is groundwork for making special remotes like borg be skipped by sync when on an offline drive. Added AVAILABILITY UNAVAILABLE reponse and the UNAVAILABLERESPONSE extension to the external special remote protocol. The extension is needed because old git-annex, if it sees that response, will display a warning message. (It does continue as if the remote is globally available, which is acceptable, and the warning is only displayed at initremote due to remote.name.annex-availability caching, but still it seemed best to make this a protocol extension.) The remote.name.annex-availability git config is no longer used any more, and is documented as such. It was only used by external special remotes to cache the availability, to avoid needing to start the external process every time. Now that availability is queried as an Annex action, the external is only started by sync (and the assistant), when they actually check availability. Sponsored-by: Nicholas Golder-Manning on Patreon
This commit is contained in:
parent
7f7c95b771
commit
9286769d2c
28 changed files with 86 additions and 65 deletions
|
@ -1,6 +1,6 @@
|
|||
{- Standard git remotes.
|
||||
-
|
||||
- Copyright 2011-2021 Joey Hess <id@joeyh.name>
|
||||
- Copyright 2011-2023 Joey Hess <id@joeyh.name>
|
||||
-
|
||||
- Licensed under the GNU AGPL version 3 or higher.
|
||||
-}
|
||||
|
@ -11,7 +11,6 @@
|
|||
module Remote.Git (
|
||||
remote,
|
||||
configRead,
|
||||
repoAvail,
|
||||
onLocalRepo,
|
||||
) where
|
||||
|
||||
|
@ -210,7 +209,7 @@ gen r u rc gc rs
|
|||
, readonly = Git.repoIsHttp r
|
||||
, appendonly = False
|
||||
, untrustworthy = False
|
||||
, availability = availabilityCalc r
|
||||
, availability = repoAvail r
|
||||
, remotetype = remote
|
||||
, mkUnavailable = unavailable r u rc gc rs
|
||||
, getInfo = gitRepoInfo new
|
||||
|
@ -233,20 +232,24 @@ unavailable r = gen r'
|
|||
_ -> r -- already unavailable
|
||||
|
||||
{- Checks relatively inexpensively if a repository is available for use. -}
|
||||
repoAvail :: Git.Repo -> Annex Bool
|
||||
repoAvail :: Git.Repo -> Annex Availability
|
||||
repoAvail r
|
||||
| Git.repoIsHttp r = return True
|
||||
| Git.repoIsHttp r = return GloballyAvailable
|
||||
| Git.GCrypt.isEncrypted r = do
|
||||
g <- gitRepo
|
||||
liftIO $ do
|
||||
er <- Git.GCrypt.encryptedRemote g r
|
||||
if Git.repoIsLocal er || Git.repoIsLocalUnknown er
|
||||
then catchBoolIO $
|
||||
void (Git.Config.read er) >> return True
|
||||
else return True
|
||||
| Git.repoIsUrl r = return True
|
||||
| Git.repoIsLocalUnknown r = return False
|
||||
| otherwise = liftIO $ isJust <$> catchMaybeIO (Git.Config.read r)
|
||||
then checklocal er
|
||||
else return GloballyAvailable
|
||||
| Git.repoIsUrl r = return GloballyAvailable
|
||||
| Git.repoIsLocalUnknown r = return Unavailable
|
||||
| otherwise = checklocal r
|
||||
where
|
||||
checklocal r' = ifM (liftIO $ isJust <$> catchMaybeIO (Git.Config.read r'))
|
||||
( return LocallyAvailable
|
||||
, return Unavailable
|
||||
)
|
||||
|
||||
{- Tries to read the config for a specified remote, updates state, and
|
||||
- returns the updated repo. -}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue