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.
 | 
			
		||||
  * 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
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue