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:
parent
7f15339162
commit
abe4b7ebd6
2 changed files with 18 additions and 13 deletions
|
@ -2,6 +2,8 @@ git-annex (7.20181032) UNRELEASED; urgency=medium
|
||||||
|
|
||||||
* Increase minimum QuickCheck version.
|
* Increase minimum QuickCheck version.
|
||||||
* Fix a P2P protocol hang.
|
* 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
|
-- Joey Hess <id@joeyh.name> Wed, 31 Oct 2018 15:53:03 -0400
|
||||||
|
|
||||||
|
|
|
@ -78,21 +78,18 @@ perform :: ImportFeedOptions -> Cache -> URLString -> CommandPerform
|
||||||
perform opts cache url = do
|
perform opts cache url = do
|
||||||
v <- findDownloads url
|
v <- findDownloads url
|
||||||
case v of
|
case v of
|
||||||
[] -> do
|
[] -> next $
|
||||||
feedProblem url "bad feed content; no enclosures to download"
|
feedProblem url "bad feed content; no enclosures to download"
|
||||||
next $ return True
|
|
||||||
l -> do
|
l -> do
|
||||||
showOutput
|
showOutput
|
||||||
ok <- and <$> mapM (performDownload opts cache) l
|
ok <- and <$> mapM (performDownload opts cache) l
|
||||||
unless ok $
|
next $ cleanup url ok
|
||||||
feedProblem url "problem downloading some item(s) from feed"
|
|
||||||
next $ cleanup url True
|
|
||||||
|
|
||||||
cleanup :: URLString -> Bool -> CommandCleanup
|
cleanup :: URLString -> Bool -> CommandCleanup
|
||||||
cleanup url ok = do
|
cleanup url True = do
|
||||||
when ok $
|
clearFeedProblem url
|
||||||
clearFeedProblem url
|
return True
|
||||||
return ok
|
cleanup url False = feedProblem url "problem downloading some item(s) from feed"
|
||||||
|
|
||||||
data ToDownload = ToDownload
|
data ToDownload = ToDownload
|
||||||
{ feed :: Feed
|
{ feed :: Feed
|
||||||
|
@ -370,11 +367,17 @@ noneValue :: String
|
||||||
noneValue = "none"
|
noneValue = "none"
|
||||||
|
|
||||||
{- Called when there is a problem with a feed.
|
{- 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)
|
feedProblem url message = ifM (checkFeedBroken url)
|
||||||
( giveup $ message ++ " (having repeated problems with feed: " ++ url ++ ")"
|
( do
|
||||||
, warning $ "warning: " ++ message
|
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
|
{- A feed is only broken if problems have occurred repeatedly, for at
|
||||||
|
|
Loading…
Reference in a new issue