fix(worker): More robust purge implementation for S3 annex keys #3172
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.
Fixes several issues with the purge annex key implementation. git-annex does not output ok in the success case here and with force allows you to call purge on any annex key regardless of it if exists or not. Just checking the exit code here should be sufficient to make sure git-annex ran as expected.
We also need to check every S3 URL for a key, previously this would delete one versionId at a time. It's very common for a key to be exported under two versions on S3 and this will remove all copies (including those associated with another file path).
In the future we may need to filter to OpenNeuro created remotes. Need to consider this for several situations with sparse datasets where content is only held remotely.