distinguish between feed download and parse failures
This commit is contained in:
parent
6f846f4c38
commit
0f78b4db09
1 changed files with 11 additions and 9 deletions
|
@ -77,7 +77,9 @@ perform :: ImportFeedOptions -> Cache -> URLString -> CommandPerform
|
||||||
perform opts cache url = go =<< downloadFeed url
|
perform opts cache url = go =<< downloadFeed url
|
||||||
where
|
where
|
||||||
go Nothing = next $ feedProblem url "downloading the feed failed"
|
go Nothing = next $ feedProblem url "downloading the feed failed"
|
||||||
go (Just f) = case findDownloads url f of
|
go (Just feedcontent) = case parseFeedString feedcontent of
|
||||||
|
Nothing -> next $ feedProblem url "parsing the feed failed"
|
||||||
|
Just f -> case findDownloads url f of
|
||||||
[] -> next $
|
[] -> next $
|
||||||
feedProblem url "bad feed content; no enclosures to download"
|
feedProblem url "bad feed content; no enclosures to download"
|
||||||
l -> do
|
l -> do
|
||||||
|
@ -142,14 +144,14 @@ findDownloads u f = catMaybes $ map mk (feedItems f)
|
||||||
Nothing -> Nothing
|
Nothing -> Nothing
|
||||||
|
|
||||||
{- Feeds change, so a feed download cannot be resumed. -}
|
{- Feeds change, so a feed download cannot be resumed. -}
|
||||||
downloadFeed :: URLString -> Annex (Maybe Feed)
|
downloadFeed :: URLString -> Annex (Maybe String)
|
||||||
downloadFeed url
|
downloadFeed url
|
||||||
| Url.parseURIRelaxed url == Nothing = giveup "invalid feed url"
|
| Url.parseURIRelaxed url == Nothing = giveup "invalid feed url"
|
||||||
| otherwise = Url.withUrlOptions $ \uo ->
|
| otherwise = Url.withUrlOptions $ \uo ->
|
||||||
liftIO $ withTmpFile "feed" $ \f h -> do
|
liftIO $ withTmpFile "feed" $ \f h -> do
|
||||||
hClose h
|
hClose h
|
||||||
ifM (Url.download nullMeterUpdate url f uo)
|
ifM (Url.download nullMeterUpdate url f uo)
|
||||||
( parseFeedString <$> readFileStrict f
|
( Just <$> readFileStrict f
|
||||||
, return Nothing
|
, return Nothing
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue