File tree Expand file tree Collapse file tree 5 files changed +44
-0
lines changed Expand file tree Collapse file tree 5 files changed +44
-0
lines changed Original file line number Diff line number Diff line change 790
790
"command" : " codeQL.trimCache" ,
791
791
"title" : " CodeQL: Trim Cache"
792
792
},
793
+ {
794
+ "command" : " codeQL.trimOverlayBaseCache" ,
795
+ "title" : " CodeQL: Trim Overlay Base Cache" ,
796
+ "when" : " codeQL.cliFeatures.queryServerModeInTrimCache"
797
+ },
793
798
{
794
799
"command" : " codeQL.installPackDependencies" ,
795
800
"title" : " CodeQL: Install Pack Dependencies"
Original file line number Diff line number Diff line change @@ -221,6 +221,7 @@ export type LocalDatabasesCommands = {
221
221
"codeQL.upgradeCurrentDatabase" : ( ) => Promise < void > ;
222
222
"codeQL.clearCache" : ( ) => Promise < void > ;
223
223
"codeQL.trimCache" : ( ) => Promise < void > ;
224
+ "codeQL.trimOverlayBaseCache" : ( ) => Promise < void > ;
224
225
225
226
// Explorer context menu
226
227
"codeQL.setCurrentDatabase" : ( uri : Uri ) => Promise < void > ;
Original file line number Diff line number Diff line change @@ -284,6 +284,7 @@ export class DatabaseUI extends DisposableObject {
284
284
this . handleUpgradeCurrentDatabase . bind ( this ) ,
285
285
"codeQL.clearCache" : this . handleClearCache . bind ( this ) ,
286
286
"codeQL.trimCache" : this . handleTrimCache . bind ( this ) ,
287
+ "codeQL.trimOverlayBaseCache" : this . handleTrimOverlayBaseCache . bind ( this ) ,
287
288
"codeQLDatabases.chooseDatabaseFolder" :
288
289
this . handleChooseDatabaseFolder . bind ( this ) ,
289
290
"codeQLDatabases.chooseDatabaseArchive" :
@@ -688,6 +689,24 @@ export class DatabaseUI extends DisposableObject {
688
689
) ;
689
690
}
690
691
692
+ private async handleTrimOverlayBaseCache ( ) : Promise < void > {
693
+ return withProgress (
694
+ async ( ) => {
695
+ if (
696
+ this . queryServer !== undefined &&
697
+ this . databaseManager . currentDatabaseItem !== undefined
698
+ ) {
699
+ await this . queryServer . trimOverlayBaseCacheInDatabase (
700
+ this . databaseManager . currentDatabaseItem ,
701
+ ) ;
702
+ }
703
+ } ,
704
+ {
705
+ title : "Removing all overlay-dependent data from cache" ,
706
+ } ,
707
+ ) ;
708
+ }
709
+
691
710
private async handleGetCurrentDatabase ( ) : Promise < string | undefined > {
692
711
const dbItem = await this . getDatabaseItemInternal ( undefined ) ;
693
712
return dbItem ?. databaseUri . fsPath ;
Original file line number Diff line number Diff line change @@ -40,6 +40,10 @@ export interface TrimCacheParams {
40
40
* The dataset that we want to trim the cache of.
41
41
*/
42
42
db : string ;
43
+ /**
44
+ * The cache cleanup mode to use (default: "trim")
45
+ */
46
+ mode ?: "clear" | "trim" | "fit" | "overlay" ;
43
47
}
44
48
45
49
/**
Original file line number Diff line number Diff line change @@ -142,6 +142,21 @@ export class QueryRunner {
142
142
await this . qs . sendRequest ( trimCache , params ) ;
143
143
}
144
144
145
+ async trimOverlayBaseCacheInDatabase ( dbItem : DatabaseItem ) : Promise < void > {
146
+ if ( dbItem . contents === undefined ) {
147
+ throw new Error (
148
+ "Can't trim the overlay base cache in an invalid database." ,
149
+ ) ;
150
+ }
151
+
152
+ const db = dbItem . databaseUri . fsPath ;
153
+ const params : TrimCacheParams = {
154
+ db,
155
+ mode : "overlay" ,
156
+ } ;
157
+ await this . qs . sendRequest ( trimCache , params ) ;
158
+ }
159
+
145
160
public async compileAndRunQueryAgainstDatabaseCore (
146
161
dbPath : string ,
147
162
queries : CoreQueryTarget [ ] ,
You can’t perform that action at this time.
0 commit comments