avoid hanging on exception

This commit is contained in:
Joey Hess 2020-07-13 12:36:15 -04:00
parent bff5694f55
commit 918b1faa3d
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
3 changed files with 20 additions and 6 deletions

View file

@ -267,19 +267,21 @@ seekFiltered a fs = do
-- This is significantly faster than using lookupKey after seekFiltered. -- This is significantly faster than using lookupKey after seekFiltered.
seekFilteredKeys :: (RawFilePath -> Key -> CommandSeek) -> Annex [(RawFilePath, Git.Sha, FileMode)] -> Annex () seekFilteredKeys :: (RawFilePath -> Key -> CommandSeek) -> Annex [(RawFilePath, Git.Sha, FileMode)] -> Annex ()
seekFilteredKeys a fs = do seekFilteredKeys a listfs = do
g <- Annex.gitRepo g <- Annex.gitRepo
matcher <- Limit.getMatcher matcher <- Limit.getMatcher
-- Run here, not in the async, because it could throw an exception
-- The list should be built lazily.
l <- listfs
catObjectStream g $ \feeder closer reader -> do catObjectStream g $ \feeder closer reader -> do
processertid <- liftIO . async =<< forkState processertid <- liftIO . async =<< forkState
(gofeed matcher feeder closer) (gofeed l matcher feeder closer)
goread reader goread reader
join (liftIO (wait processertid)) join (liftIO (wait processertid))
where where
gofeed matcher feeder closer = do gofeed l matcher feeder closer =
l <- fs forM_ l (process matcher feeder)
forM_ l $ process matcher feeder `finally` liftIO closer
liftIO closer
goread reader = liftIO reader >>= \case goread reader = liftIO reader >>= \case
Just (f, content) -> do Just (f, content) -> do

View file

@ -50,3 +50,5 @@ git-annex: Not recursively setting metadata. Use --force to do that.
[[!meta author=kyle]] [[!meta author=kyle]]
[[!tag projects/datalad]] [[!tag projects/datalad]]
> [[fixed|done]] --[[Joey]]

View file

@ -0,0 +1,10 @@
[[!comment format=mdwn
username="joey"
subject="""comment 1"""
date="2020-07-13T16:24:55Z"
content="""
Aha, seekFilteredKeys is not prepared for the file list action that's
passed to it to throw an exception, but in this one case at least, it can.
Thanks for reporting, I've fixed it.
"""]]