importfeed: Error out when passed a non-url.

This commit is contained in:
Joey Hess 2015-04-09 13:09:06 -04:00
parent aa31af5594
commit 3695094454
3 changed files with 19 additions and 9 deletions

View file

@ -146,15 +146,17 @@ findDownloads u = go =<< downloadFeed u
{- Feeds change, so a feed download cannot be resumed. -}
downloadFeed :: URLString -> Annex (Maybe Feed)
downloadFeed url = do
showOutput
uo <- Url.getUrlOptions
liftIO $ withTmpFile "feed" $ \f h -> do
hClose h
ifM (Url.download url f uo)
( parseFeedString <$> readFileStrictAnyEncoding f
, return Nothing
)
downloadFeed url
| Url.parseURIRelaxed url == Nothing = error "invalid feed url"
| otherwise = do
showOutput
uo <- Url.getUrlOptions
liftIO $ withTmpFile "feed" $ \f h -> do
hClose h
ifM (Url.download url f uo)
( parseFeedString <$> readFileStrictAnyEncoding f
, return Nothing
)
performDownload :: Opts -> Cache -> ToDownload -> Annex Bool
performDownload opts cache todownload = case location todownload of