importfeed: Better error message when downloading the feed fails
It used to display the "bad feed content" message indicating there were no enclosures found, which was misleading when the http request for the feed failed. This commit was sponsored by Ewen McNeill on Patreon.
This commit is contained in:
parent
f943138508
commit
6512b40bac
2 changed files with 8 additions and 9 deletions
|
@ -11,6 +11,7 @@ git-annex (7.20181212) UNRELEASED; urgency=medium
|
||||||
* unused: Update suggested git log message to see where data was previously
|
* unused: Update suggested git log message to see where data was previously
|
||||||
used so it will also work with v7 unlocked pointer files.
|
used so it will also work with v7 unlocked pointer files.
|
||||||
* Fix doubled progress display when downloading an url when -J is used.
|
* Fix doubled progress display when downloading an url when -J is used.
|
||||||
|
* importfeed: Better error message when downloading the feed fails.
|
||||||
|
|
||||||
-- Joey Hess <id@joeyh.name> Tue, 18 Dec 2018 12:24:52 -0400
|
-- Joey Hess <id@joeyh.name> Tue, 18 Dec 2018 12:24:52 -0400
|
||||||
|
|
||||||
|
|
|
@ -75,9 +75,10 @@ start opts cache url = do
|
||||||
next $ perform opts cache url
|
next $ perform opts cache url
|
||||||
|
|
||||||
perform :: ImportFeedOptions -> Cache -> URLString -> CommandPerform
|
perform :: ImportFeedOptions -> Cache -> URLString -> CommandPerform
|
||||||
perform opts cache url = do
|
perform opts cache url = go =<< downloadFeed url
|
||||||
v <- findDownloads url
|
where
|
||||||
case v of
|
go Nothing = next $ feedProblem url "downloading the feed failed"
|
||||||
|
go (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
|
||||||
|
@ -128,13 +129,10 @@ knownItems (k, u) = do
|
||||||
<$> getCurrentMetaData k
|
<$> getCurrentMetaData k
|
||||||
return (itemids, u)
|
return (itemids, u)
|
||||||
|
|
||||||
findDownloads :: URLString -> Annex [ToDownload]
|
findDownloads :: URLString -> Feed -> [ToDownload]
|
||||||
findDownloads u = go <$> downloadFeed u
|
findDownloads u f = catMaybes $ map mk (feedItems f)
|
||||||
where
|
where
|
||||||
go Nothing = []
|
mk i = case getItemEnclosure i of
|
||||||
go (Just f) = catMaybes $ map (mk f) (feedItems f)
|
|
||||||
|
|
||||||
mk f i = case getItemEnclosure i of
|
|
||||||
Just (enclosureurl, _, _) ->
|
Just (enclosureurl, _, _) ->
|
||||||
Just $ ToDownload f u i $ Enclosure $
|
Just $ ToDownload f u i $ Enclosure $
|
||||||
fromFeed enclosureurl
|
fromFeed enclosureurl
|
||||||
|
|
Loading…
Reference in a new issue