catch all (non-async) exceptions when running a commandAction
When a command is operating on multiple files and there's an error with one, try harder to continue to the rest. (As was already done for many types of errors including IO errors.) This handles cases like lockContentForRemoval throwing an exception when the content is already locked. Just because a drop of one file fails, does not mean it shouldn't go on to try to drop other files. I looked over uses of `giveup` in Command/*; there are too many to check them all extensively, but none stood out as being problems that should let one commandAction stop running other commandActions. Worst case, something bad will happen and rather than stopping right away with an error, git-annex will display multiple errors as it fails over and over on each file. I don't think I ever really intended `error`/`giveup` to stop other commandActions; this was a relic of old confusion over haskell exception handling. Test suite passes. This commit was sponsored by Ethan Aubin.
This commit is contained in:
parent
c8bd5710b1
commit
39fbaa0682
3 changed files with 17 additions and 3 deletions
|
@ -18,6 +18,9 @@ git-annex (7.20181106) UNRELEASED; urgency=medium
|
|||
diff, avoid erroring out.
|
||||
* drop -J: Avoid processing the same key twice at the same time when
|
||||
multiple annexes files use it.
|
||||
* When a command is operating on multiple files and there's an error
|
||||
with one, try harder to continue to the rest. (As was already done
|
||||
for many types of errors including IO errors.)
|
||||
|
||||
-- Joey Hess <id@joeyh.name> Tue, 06 Nov 2018 12:44:27 -0400
|
||||
|
||||
|
|
|
@ -43,8 +43,7 @@ performCommandAction Command { cmdcheck = c, cmdname = name } seek cont = do
|
|||
|
||||
{- Runs one of the actions needed to perform a command.
|
||||
- Individual actions can fail without stopping the whole command,
|
||||
- including by throwing IO errors (but other errors terminate the whole
|
||||
- command).
|
||||
- including by throwing non-async exceptions.
|
||||
-
|
||||
- When concurrency is enabled, a thread is forked off to run the action
|
||||
- in the background, as soon as a free slot is available.
|
||||
|
@ -128,7 +127,7 @@ findFreeSlot = go []
|
|||
|
||||
{- Like commandAction, but without the concurrency. -}
|
||||
includeCommandAction :: CommandStart -> CommandCleanup
|
||||
includeCommandAction a = account =<< tryIO (callCommandAction a)
|
||||
includeCommandAction a = account =<< tryNonAsync (callCommandAction a)
|
||||
where
|
||||
account (Right True) = return True
|
||||
account (Right False) = incerr
|
||||
|
|
|
@ -29,3 +29,15 @@ local repository version: 5
|
|||
Linux ip-172-31-87-156 4.14.72-68.55.amzn1.x86_64 #1 SMP Fri Sep 28 21:14:54 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
|
||||
|
||||
### Please provide any additional information below.
|
||||
|
||||
> Made drop not operate on the same key multiple times concurrently.
|
||||
>
|
||||
> Also yeah, that kind of exception should not interrupt processing other
|
||||
> files; the distinction git-annex has drawn between IO errors and other
|
||||
> exceptions is not super useful unless a command for some reason wants to
|
||||
> completely stop everything for some reason. I can't think of any cases
|
||||
> where a command would want to do that; if it does turn out to be needed,
|
||||
> a special type of exception could be thrown to force termination.
|
||||
> So I changed it to catch all (non-async) errors.
|
||||
>
|
||||
> [[fixed|done]] --[[Joey]]
|
||||
|
|
Loading…
Reference in a new issue