check file exists before using bolt.Open #146
Merged
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.
Hi All,
Thank you for your dedicated work on this wonderful project. I was in the process of building something similar and was delighted to come across your existing efforts.
I wanted to address an issue I encountered while using auger with the -f extract option when specifying an etcd snapshot that does not exist.
As many of you may know, this utility uses the
bolt "go.etcd.io/bbolt"
library.When opening files, it will automatically create a new file if it does not exist. This behaviour is depicted in the following example from the Bolt repository:
Although this functionality is useful in some contexts, it becomes problematic for us when attempting to access an existing snapshot. Specifically, we do not want to inadvertently create a zero-length file if an incorrect filename is provided.
This pull request introduces a straightforward fix by adding a preliminary OS check before executing
bolt.Open
. It also improves user feedback by clarifying error messages when files do not exist. An example with this change implemented:As expected when the snapshot file exists auger works as expected -
I believe this improvement will prevent any unintended file creation and provide clearer guidance when files are missing.
Hope this helps and looking forward to your feedback on this proposal.