[Feature response] Retry the unmounting operation 3 times #118
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Fixed #115
Related to #114 .
Added 3 attempts with backoff. I borrowed ideas from LinusU/node-appdmg#190 and modified the number of attempts from 5 to 3 per @aonez's suggestion (#115 (comment)).
Programming
set ±e
A temporary
set +e
is not required since the exit code of the statement executed in the {until... do} block is used to determine whether the {do... done} block will be executed. In other words, a non-zero exit code in the {until... do} block will not terminate the execution of a script withset -e
. Therefore, we can safely test the exit code ofhdiutil detach
.You can search "Exit immediately" in bash's manual page to see the official description.
how does it work
A small mock script:
Execute it:
Test
I tested this on GitHub Actions. In the workflow, I tried to package Firefox like this:
And it works!
Log:
Statistics:
How to do statistics: By adding
echo "::warning EBUSY"
, I'm able to know how many instances retried the unmounting operation without checking the logs of all instances one by one.Please review my code, thank you.