From 7264203eb1c6b22183459ef6a9b2f1c013e996b9 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 20 Jun 2019 12:37:07 -0400 Subject: [PATCH] importfeed: When there's a problem parsing the feed, --debug will output the feed content that was downloaded. And let the user know about it in the failure messages. --- CHANGELOG | 2 ++ Command/ImportFeed.hs | 16 ++++++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 8b050c6db6..5bf1204f40 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -10,6 +10,8 @@ git-annex (7.20190616) UNRELEASED; urgency=medium avoid using http range to resume, since a range "bytes=0-" is an unusual edge case that it's best to avoid relying on working. This is known to fix a case where importfeed downloaded a partial feed from such a server. + * importfeed: When there's a problem parsing the feed, --debug will + output the feed content that was downloaded. -- Joey Hess Sat, 15 Jun 2019 12:38:25 -0400 diff --git a/Command/ImportFeed.hs b/Command/ImportFeed.hs index 1d5ad0c9c8..7a2b162920 100644 --- a/Command/ImportFeed.hs +++ b/Command/ImportFeed.hs @@ -21,6 +21,7 @@ import Data.Time.Format import System.Locale #endif import qualified Data.Text as T +import System.Log.Logger import Command import qualified Annex @@ -75,11 +76,9 @@ getFeed opts cache url = do Nothing -> showEndResult =<< feedProblem url "downloading the feed failed" Just feedcontent -> case parseFeedString feedcontent of - Nothing -> showEndResult =<< feedProblem url - "parsing the feed failed" + Nothing -> debugfeedcontent feedcontent "parsing the feed failed" Just f -> case findDownloads url f of - [] -> showEndResult =<< feedProblem url - "bad feed content; no enclosures to download" + [] -> debugfeedcontent feedcontent "bad feed content; no enclosures to download" l -> do showEndOk ifM (and <$> mapM (performDownload opts cache) l) @@ -87,6 +86,15 @@ getFeed opts cache url = do , void $ feedProblem url "problem downloading some item(s) from feed" ) + where + debugfeedcontent feedcontent msg = do + liftIO $ debugM "feed content" $ unlines + [ "start of feed content" + , feedcontent + , "end of feed content" + ] + showEndResult =<< feedProblem url + (msg ++ " (use --debug to see the feed content that was downloaded)") data ToDownload = ToDownload { feed :: Feed