🐛 (api) fix performing api operations for local e2e encrypted files #2698
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.
Originally discovered in: #2683
However, because this is fundamentally different issue - it makes more sense to separate it out into its own PR.
The problem: this only affects budgets that are using the server and that are e2e encrypted.
The initial load of the e2e budget works fine. It downloads the file, decrypts it and stores it locally. But then the subsequent run might fail.
This is because on subsequent runs we no longer download the entire file. We use the local file and just sync the changes with the server. However, this requires the encryption key to be set. And encryption key was ONLY set for the initial run. it was not set for subsequent runs.
Thus it resulted in the API script breaking.
--
The fix is relatively simple: set the encryption key even always. Even if the remote file was already downloaded.
But this required a small amount of refactoring to make the code cleaner