File tree Expand file tree Collapse file tree 2 files changed +24
-19
lines changed
extensions/ql-vscode/src/variant-analysis Expand file tree Collapse file tree 2 files changed +24
-19
lines changed Original file line number Diff line number Diff line change @@ -22,18 +22,23 @@ export async function writeRepoStates(
2222
2323export async function readRepoStates (
2424 storagePath : string ,
25- ) : Promise < Record < number , VariantAnalysisScannedRepositoryState > > {
26- const repoStatesData : Record <
27- number ,
28- VariantAnalysisScannedRepositoryStateData
29- > = await readJson ( storagePath ) ;
25+ ) : Promise < Record < number , VariantAnalysisScannedRepositoryState > | undefined > {
26+ try {
27+ const repoStatesData : Record <
28+ number ,
29+ VariantAnalysisScannedRepositoryStateData
30+ > = await readJson ( storagePath ) ;
3031
31- // Map from repoStates Data type to the repoStates Domain type
32- const repoStates = Object . fromEntries (
33- Object . entries ( repoStatesData ) . map ( ( [ key , value ] ) => {
34- return [ key , mapRepoStateToDomain ( value ) ] ;
35- } ) ,
36- ) ;
32+ // Map from repoStates Data type to the repoStates Domain type
33+ const repoStates = Object . fromEntries (
34+ Object . entries ( repoStatesData ) . map ( ( [ key , value ] ) => {
35+ return [ key , mapRepoStateToDomain ( value ) ] ;
36+ } ) ,
37+ ) ;
3738
38- return repoStates ;
39+ return repoStates ;
40+ } catch ( e ) {
41+ // Ignore this error, we simply might not have downloaded anything yet
42+ return undefined ;
43+ }
3944}
Original file line number Diff line number Diff line change @@ -264,13 +264,13 @@ export class VariantAnalysisManager
264264 } else {
265265 await this . setVariantAnalysis ( variantAnalysis ) ;
266266
267- try {
268- const repoStates = await readRepoStates (
269- this . getRepoStatesStoragePath ( variantAnalysis . id ) ,
270- ) ;
271- this . repoStates . set ( variantAnalysis . id , repoStates ) ;
272- } catch ( e ) {
273- // Ignore this error, we simply might not have downloaded anything yet
267+ const repoStatesFromDisk = await readRepoStates (
268+ this . getRepoStatesStoragePath ( variantAnalysis . id ) ,
269+ ) ;
270+
271+ if ( repoStatesFromDisk ) {
272+ this . repoStates . set ( variantAnalysis . id , repoStatesFromDisk ) ;
273+ } else {
274274 this . repoStates . set ( variantAnalysis . id , { } ) ;
275275 }
276276
You can’t perform that action at this time.
0 commit comments