addurl, importfeed: Added --raw-except option

--raw-except=web allows using yt-dlp but not any other special remotes.

Currently this option can only be used once, trying to use it repeatedly
will make option parsing fail. Perhaps it ought to support being used more
than once, but it seemed like an unlikely use case to need that.

Note that getParsed is called repeatedly when the option is used with
several urls. While implementing DeferredParseClass would avoid that
innefficiency, it didn't seem worth the added boilerplate since
getParsed only calls byNameWithUUID which does minimal work.

Sponsored-by: Dartmouth College's DANDI project
This commit is contained in:
Joey Hess 2024-02-05 15:16:25 -04:00
parent c0c85a7de4
commit 6b38d0c427
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
7 changed files with 54 additions and 15 deletions

View file

@ -1,6 +1,6 @@
{- git-annex remotes
-
- Copyright 2011-2020 Joey Hess <id@joeyh.name>
- Copyright 2011-2024 Joey Hess <id@joeyh.name>
-
- Licensed under the GNU AGPL version 3 or higher.
-}
@ -59,6 +59,7 @@ module Remote (
logStatus,
checkAvailable,
claimingUrl,
claimingUrl',
isExportSupported,
) where
@ -432,9 +433,15 @@ hasKeyCheap = checkPresentCheap
{- The web special remote claims urls by default. -}
claimingUrl :: URLString -> Annex Remote
claimingUrl url = do
claimingUrl = claimingUrl' (const True)
{- The web special remote still claims urls if there is no
- other remote that does, even when the remotefilter does
- not include it. -}
claimingUrl' :: (Remote -> Bool) -> URLString -> Annex Remote
claimingUrl' remotefilter url = do
rs <- remoteList
let web = Prelude.head $ filter (\r -> uuid r == webUUID) rs
fromMaybe web <$> firstM checkclaim rs
fromMaybe web <$> firstM checkclaim (filter remotefilter rs)
where
checkclaim = maybe (pure False) (`id` url) . claimUrl