Store state of CodeQL distribution on filesystem instead of in globalState
#3762
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.
The
globalState
is shared between all VS Code instances, regardless of whether they are local or remote (e.g. Codespaces, SSH). Since the distribution (i.e. the CodeQL CLI) is stored on the filesystem, this does not always match theglobalState
(e.g. when switching between local and Codespaces).This fixes that problem by also storing the distribution state on the local filesystem in a
distribution.json
file. This file contains the same information as theglobalState
did, but is local to each filesystem. For example, this is what it contains on my machine:The migration to this format is quite trivial: if the
distribution.json
file doesn't exist, take the values fromglobalState
and create it. We can then always use thedistribution.json
file.In addition, this adds a filesystem-based lock when updating the distribution. This ensures that there are no race conditions between multiple VS Code instances when they all try to update the distribution.