importfeed: Avoid erroring out when a feed has been repeatedly broken

That can leave other imported files not checked into git, because the git
command queue is not flushed when git-annex errors out. And since it only
happens once git-annex has concluded a feed is broken, it's an intermittent
bug, worst kind. Been seeing it for a while, only tracked down today.

Instead, by returning False, git-annex importfeed will cleanly shutdown and
still exit nonzero.

This commit was sponsored by Denis Dzyubenko on Patreon.
This commit is contained in:
Joey Hess 2018-11-04 17:41:49 -04:00
parent 7f15339162
commit abe4b7ebd6
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
2 changed files with 18 additions and 13 deletions

View file

@ -2,6 +2,8 @@ git-annex (7.20181032) UNRELEASED; urgency=medium
* Increase minimum QuickCheck version.
* Fix a P2P protocol hang.
* importfeed: Avoid erroring out when a feed has been repeatedly broken,
as that can leave other imported files not checked into git.
-- Joey Hess <id@joeyh.name> Wed, 31 Oct 2018 15:53:03 -0400

View file

@ -78,21 +78,18 @@ perform :: ImportFeedOptions -> Cache -> URLString -> CommandPerform
perform opts cache url = do
v <- findDownloads url
case v of
[] -> do
[] -> next $
feedProblem url "bad feed content; no enclosures to download"
next $ return True
l -> do
showOutput
ok <- and <$> mapM (performDownload opts cache) l
unless ok $
feedProblem url "problem downloading some item(s) from feed"
next $ cleanup url True
next $ cleanup url ok
cleanup :: URLString -> Bool -> CommandCleanup
cleanup url ok = do
when ok $
cleanup url True = do
clearFeedProblem url
return ok
return True
cleanup url False = feedProblem url "problem downloading some item(s) from feed"
data ToDownload = ToDownload
{ feed :: Feed
@ -370,11 +367,17 @@ noneValue :: String
noneValue = "none"
{- Called when there is a problem with a feed.
- Throws an error if the feed is broken, otherwise shows a warning. -}
feedProblem :: URLString -> String -> Annex ()
-
- If the feed has been broken for some time,
- returns False, otherwise only warns. -}
feedProblem :: URLString -> String -> Annex Bool
feedProblem url message = ifM (checkFeedBroken url)
( giveup $ message ++ " (having repeated problems with feed: " ++ url ++ ")"
, warning $ "warning: " ++ message
( do
warning $ message ++ " (having repeated problems with feed: " ++ url ++ ")"
return False
, do
warning $ "warning: " ++ message
return True
)
{- A feed is only broken if problems have occurred repeatedly, for at