addurl = addUrlChecked o url file webUUID $ \k ->
ifM (pure (not (rawOption (downloadOptions o))) <&&> youtubeDlSupported url)
( return (True, True, setDownloader url YoutubeDownloader)
- , checkRaw (downloadOptions o) $ return (Url.urlExists urlinfo, Url.urlSize urlinfo == fromKey keySize k, url)
+ , checkRaw Nothing (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 _ -> checkRaw o (normalfinish tmp)
+ Left err -> checkRaw (Just err) 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 -> checkRaw o (normalfinish tmp)
+ Right Nothing -> checkRaw Nothing o (normalfinish tmp)
Left msg -> do
cleanuptmp
warning msg
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."
+checkRaw :: (Maybe String) -> DownloadOptions -> Annex a -> Annex a
+checkRaw failreason o a
+ | noRawOption o = giveup $ "Unable to use youtube-dl or a special remote and --no-raw was specified" ++
+ case failreason of
+ Just msg -> ": " ++ msg
+ Nothing -> ""
| otherwise = a
{- The destination file is not known at start time unless the user provided
then nomedia
else youtubeDlFileName url >>= \case
Right mediafile -> usemedia (toRawFilePath mediafile)
- Left _ -> checkRaw o nomedia
+ Left err -> checkRaw (Just err) o nomedia
| otherwise = do
warning $ "unable to access url: " ++ url
return Nothing
let f' = fromRawFilePath f
r <- Remote.claimingUrl url
if Remote.uuid r == webUUID || rawOption (downloadOptions opts)
- then checkRaw (downloadOptions opts) $ do
+ then checkRaw Nothing (downloadOptions opts) $ do
let dlopts = (downloadOptions opts)
-- force using the filename
-- chosen here
, downloadlink
)
where
- downloadlink = checkRaw (downloadOptions opts) $
+ downloadlink = checkRaw Nothing (downloadOptions opts) $
performDownload addunlockedmatcher opts cache todownload
{ location = Enclosure linkurl }