added an optional cost= configuration to all special remotes

Note that when this is specified and an older git-annex is used to
enableremote such a special remote, it will simply ignore the cost= field
and use whatever the default cost is.

In passing, fixed adb to support the remote.name.cost and
remote.name.cost-command configs.

Sponsored-by: Dartmouth College's DANDI project
This commit is contained in:
Joey Hess 2023-01-12 13:42:28 -04:00
parent 400ce29a94
commit cfaae7e931
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
25 changed files with 83 additions and 42 deletions

View file

@ -67,7 +67,7 @@ gen r u rc gc rs
-- readonly mode only downloads urls; does not use external program
| externaltype == "readonly" = do
c <- parsedRemoteConfig remote rc
cst <- remoteCost gc expensiveRemoteCost
cst <- remoteCost gc c expensiveRemoteCost
let rmt = mk c cst GloballyAvailable
Nothing
(externalInfo externaltype)
@ -86,7 +86,7 @@ gen r u rc gc rs
external <- newExternal externaltype (Just u) c (Just gc)
(Git.remoteName r) (Just rs)
Annex.addCleanupAction (RemoteCleanup u) $ stopExternal external
cst <- getCost external r gc
cst <- getCost external r gc c
avail <- getAvailability external r gc
exportsupported <- if exportTree c
then checkExportSupported' external
@ -755,9 +755,9 @@ respErrorMessage req err
{- Caches the cost in the git config to avoid needing to start up an
- external special remote every time time just to ask it what its
- cost is. -}
getCost :: External -> Git.Repo -> RemoteGitConfig -> Annex Cost
getCost external r gc =
(go =<< remoteCost' gc) `catchNonAsync` const (pure defcst)
getCost :: External -> Git.Repo -> RemoteGitConfig -> ParsedRemoteConfig -> Annex Cost
getCost external r gc pc =
(go =<< remoteCost' gc pc) `catchNonAsync` const (pure defcst)
where
go (Just c) = return c
go Nothing = do