age: create outfile as late as possible #169
Closed
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.
age
creates empty output files, when something goes wrong. Examples:age -p -o data.age data
when I enter non matching passphrases.age -d -o data data.age
when I enter the wrong passphrase.age -d -i key -o data data.age
when I provided the wrong secret key.This pull requests ensures, that the output file is created as late as possible and thus avoids the creation of empty files for the given examples. Unfortunately this leads to some boilerplate, but I feel like it's not too bad.
One drawback is that the user is now informed later about already existing output files. Thus they may have already entered a password, only to be informed that the output file already exists and won't be overwritten. This could be prevented by checking if the file exists in advance. Let me know if you want this implemented.
This pull request should resolve #159 and to some extend #57.