From 6512b40bac4a9836c45a129f62a79e922a7c016b Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sun, 30 Dec 2018 16:14:55 -0400 Subject: [PATCH] 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. --- CHANGELOG | 1 + Command/ImportFeed.hs | 16 +++++++--------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 567c58e16a..ff94a13688 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -11,6 +11,7 @@ git-annex (7.20181212) UNRELEASED; urgency=medium * unused: Update suggested git log message to see where data was previously used so it will also work with v7 unlocked pointer files. * Fix doubled progress display when downloading an url when -J is used. + * importfeed: Better error message when downloading the feed fails. -- Joey Hess Tue, 18 Dec 2018 12:24:52 -0400 diff --git a/Command/ImportFeed.hs b/Command/ImportFeed.hs index b179ee0a3f..fd36fdcc47 100644 --- a/Command/ImportFeed.hs +++ b/Command/ImportFeed.hs @@ -75,9 +75,10 @@ start opts cache url = do next $ perform opts cache url perform :: ImportFeedOptions -> Cache -> URLString -> CommandPerform -perform opts cache url = do - v <- findDownloads url - case v of +perform opts cache url = go =<< downloadFeed url + where + go Nothing = next $ feedProblem url "downloading the feed failed" + go (Just f) = case findDownloads url f of [] -> next $ feedProblem url "bad feed content; no enclosures to download" l -> do @@ -128,13 +129,10 @@ knownItems (k, u) = do <$> getCurrentMetaData k return (itemids, u) -findDownloads :: URLString -> Annex [ToDownload] -findDownloads u = go <$> downloadFeed u +findDownloads :: URLString -> Feed -> [ToDownload] +findDownloads u f = catMaybes $ map mk (feedItems f) where - go Nothing = [] - go (Just f) = catMaybes $ map (mk f) (feedItems f) - - mk f i = case getItemEnclosure i of + mk i = case getItemEnclosure i of Just (enclosureurl, _, _) -> Just $ ToDownload f u i $ Enclosure $ fromFeed enclosureurl