This commit adds a check if a results artifact already exists before
trying to download it again.
This is not a complete solution since the page icon will still have a
download button even if the artifact already exists. In this case,
clicking on it will avoid downloading it a second time.
The next step is to read in the downloaded artifacts and display them
appropriately.
Remote query items will be stored in query history and will remain
available across restarts.
When the extension is restarted, any `InProgress` remote queries will
be monitored until they complete.
When clicked on, a remote query is opened and its results can be
downloaded. The query text and the query file can be opened from the
history menu. A remote query can be deleted as well, which will purge
all results from global storage.
Limitations:
1. Labels are not editable
2. Running multiple queries that each run on the same repository
will have conflicting results and there will be errors when trying
to view the results of the second query. This limitation is not new,
but it is easier to hit now. See #1089.
Both of these limitations will be addressed in future PRs.
Because errors when running queries tend to have better explanations
in the query server log instead of the extension log, by default open
the query server log for query errors.
This is another incremental step on the way to saving history.
This commit adds remote items to the history view. It adds in progress
and completed icons. Users can explicitly remove items.
Here is what is _not_ working:
1. Any other query history commands like open results or open query.
2. Seeing items after a restart.
This is still an intermediate step as we start to bring in more
abstractions. I plan to implement a storage handler that will
keep track of all the different bits for a remote query.
This change builds on the previous change to ensure that sarif results
can be displayed properly. Here is what it does:
- Move prepareDownloadDirectory to the RemoteQueryManager
- Store the queryResult to disk
- Use the `artifactStorageDir` as the location where artifacts are kept
- Add `artifactStorageDir` to DownloadLink
- Ensure the webview passes around the right links.
This is a step on the way towards storing remote query history across
restarts.
This PR adds a `QueryHistoryInfo` type that is a union of two types:
`LocalQueryInfo` and `RemoteQueryInfo`.
`LocalQueryInfo` used to be called `FullQueryInfo` and `RemoteQueryInfo`
is only a skeleton right now. The body will be added later. This PR
only introduces it and changes types to make future PRs simpler.
Also, `slurp` and `splat` have been moved to the `query-serialization.ts`
module.
This moves all artifacts downloaded for a remote query into the global
storage directory. Each remote query gets its own directory. The
parent directory is the shared query storage directory.
Each remote query directory also gets a timestamp file.
With these changes, remote queries will be persisted across restarts
and deleted automatically on the same schedule as local queries.
Note: This does _not_ add remote queries to the query history view yet.
This part of the feature is coming next.
There is no new behaviour added in this commit. Just some cleanup:
- Move some shared constants to the `helpers` module
- Add comments to some of the query related modules
- Some general formatting and tidying