aboutsummaryrefslogtreecommitdiff
path: root/Command/ImportFeed.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2015-04-09 13:09:06 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2015-04-09 13:09:06 -0400
commitf1c44f9fad9c10059df99d644a62332629af89cf (patch)
treef916f5931c2087a628edcf7a8ff055e44497c1a3 /Command/ImportFeed.hs
parent7166fa150bbe98079e707ee9916434bd7e0affcc (diff)
importfeed: Error out when passed a non-url.
Diffstat (limited to 'Command/ImportFeed.hs')
-rw-r--r--Command/ImportFeed.hs20
1 files changed, 11 insertions, 9 deletions
diff --git a/Command/ImportFeed.hs b/Command/ImportFeed.hs
index ed3c3bcd3..2a278dea1 100644
--- a/Command/ImportFeed.hs
+++ b/Command/ImportFeed.hs
@@ -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