* Dropping an unused object with drop --unused or dropunused will
mark it as dead, preventing fsck --all from complaining about it
after it's been dropped from all repositories.
+ * addurl, importfeed: Added --no-raw option that forces download
+ with youtube-dl or a special remote. In particular this can avoid
+ falling back to raw download when youtube-dl is blocked for some
+ reason.
-- Joey Hess <id@joeyh.name> Mon, 21 Jun 2021 12:25:25 -0400
{- git-annex command
-
- - Copyright 2011-2020 Joey Hess <id@joeyh.name>
+ - Copyright 2011-2021 Joey Hess <id@joeyh.name>
-
- Licensed under the GNU AGPL version 3 or higher.
-}
data DownloadOptions = DownloadOptions
{ relaxedOption :: Bool
, rawOption :: Bool
+ , noRawOption :: Bool
, fileOption :: Maybe FilePath
, preserveFilenameOption :: Bool
, checkGitIgnoreOption :: CheckGitIgnore
( long "raw"
<> help "disable special handling for torrents, youtube-dl, etc"
)
+ <*> switch
+ ( long "no-raw"
+ <> help "prevent downloading raw url content, must use special handling"
+ )
<*> (if withfileoptions
then optional (strOption
( long "file" <> metavar paramFile
addurl = addUrlChecked o url file webUUID $ \k ->
ifM (pure (not (rawOption (downloadOptions o))) <&&> youtubeDlSupported url)
( return (True, True, setDownloader url YoutubeDownloader)
- , return (Url.urlExists urlinfo, Url.urlSize urlinfo == fromKey keySize k, url)
+ , checkRaw (downloadOptions o) $ return (Url.urlExists urlinfo, Url.urlSize urlinfo == fromKey keySize k, url)
)
{- Check that the url exists, and has the same size as the key,
in ifAnnexed f
(alreadyannexed (fromRawFilePath f))
(dl f)
- Left _ -> normalfinish tmp
+ Left _ -> checkRaw o (normalfinish tmp)
where
dl dest = withTmpWorkDir mediakey $ \workdir -> do
let cleanuptmp = pruneTmpWorkDirBefore tmp (liftIO . removeWhenExistsWith R.removeLink)
showDestinationFile (fromRawFilePath dest)
addWorkTree canadd addunlockedmatcher webUUID mediaurl dest mediakey (Just (toRawFilePath mediafile))
return $ Just mediakey
- Right Nothing -> normalfinish tmp
+ Right Nothing -> checkRaw o (normalfinish tmp)
Left msg -> do
cleanuptmp
warning msg
else do
warning $ dest ++ " already exists; not overwriting"
return Nothing
+
+checkRaw :: DownloadOptions -> Annex a -> Annex a
+checkRaw o a
+ | noRawOption o = giveup "Unable to use youtube-dl or a special remote and --no-raw was specified."
+ | otherwise = a
{- The destination file is not known at start time unless the user provided
- a filename. It's not displayed then for output consistency,
nodownloadWeb addunlockedmatcher o url urlinfo file
| Url.urlExists urlinfo = if rawOption o
then nomedia
- else either (const nomedia) (usemedia . toRawFilePath)
- =<< youtubeDlFileName url
+ else youtubeDlFileName url >>= \case
+ Right mediafile -> usemedia (toRawFilePath mediafile)
+ Left _ -> checkRaw o nomedia
| otherwise = do
warning $ "unable to access url: " ++ url
return Nothing
import Logs.MetaData
import Annex.MetaData
import Annex.FileMatcher
-import Command.AddUrl (addWorkTree)
+import Command.AddUrl (addWorkTree, checkRaw)
import Annex.UntrustedFilePath
import qualified Annex.Branch
import Logs
let f' = fromRawFilePath f
r <- Remote.claimingUrl url
if Remote.uuid r == webUUID || rawOption (downloadOptions opts)
- then do
+ then checkRaw (downloadOptions opts) $ do
let dlopts = (downloadOptions opts)
-- force using the filename
-- chosen here
, downloadlink
)
where
- downloadlink = performDownload addunlockedmatcher opts cache todownload
- { location = Enclosure linkurl }
+ downloadlink = checkRaw (downloadOptions opts) $
+ performDownload addunlockedmatcher opts cache todownload
+ { location = Enclosure linkurl }
addmediafast linkurl mediaurl mediakey =
ifM (pure (not (rawOption (downloadOptions opts)))