File tree Expand file tree Collapse file tree 5 files changed +72
-0
lines changed
Expand file tree Collapse file tree 5 files changed +72
-0
lines changed Original file line number Diff line number Diff line change 790790 "command" : " codeQL.trimCache" ,
791791 "title" : " CodeQL: Trim Cache"
792792 },
793+ {
794+ "command" : " codeQL.trimOverlayBaseCache" ,
795+ "title" : " CodeQL: Trim Overlay Base Cache"
796+ },
793797 {
794798 "command" : " codeQL.installPackDependencies" ,
795799 "title" : " CodeQL: Install Pack Dependencies"
18171821 },
18181822 {
18191823 "command" : " codeQL.trimCache"
1824+ },
1825+ {
1826+ "command" : " codeQL.trimOverlayBaseCache" ,
1827+ "when" : " codeQL.cliFeatures.queryServerTrimCacheWithMode"
18201828 }
18211829 ],
18221830 "editor/context" : [
Original file line number Diff line number Diff line change @@ -221,6 +221,7 @@ export type LocalDatabasesCommands = {
221221 "codeQL.upgradeCurrentDatabase" : ( ) => Promise < void > ;
222222 "codeQL.clearCache" : ( ) => Promise < void > ;
223223 "codeQL.trimCache" : ( ) => Promise < void > ;
224+ "codeQL.trimOverlayBaseCache" : ( ) => Promise < void > ;
224225
225226 // Explorer context menu
226227 "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 {
284284 this . handleUpgradeCurrentDatabase . bind ( this ) ,
285285 "codeQL.clearCache" : this . handleClearCache . bind ( this ) ,
286286 "codeQL.trimCache" : this . handleTrimCache . bind ( this ) ,
287+ "codeQL.trimOverlayBaseCache" : this . handleTrimOverlayBaseCache . bind ( this ) ,
287288 "codeQLDatabases.chooseDatabaseFolder" :
288289 this . handleChooseDatabaseFolder . bind ( this ) ,
289290 "codeQLDatabases.chooseDatabaseArchive" :
@@ -688,6 +689,25 @@ export class DatabaseUI extends DisposableObject {
688689 ) ;
689690 }
690691
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 . trimCacheWithModeInDatabase (
700+ this . databaseManager . currentDatabaseItem ,
701+ "overlay" ,
702+ ) ;
703+ }
704+ } ,
705+ {
706+ title : "Removing all overlay-dependent data from cache" ,
707+ } ,
708+ ) ;
709+ }
710+
691711 private async handleGetCurrentDatabase ( ) : Promise < string | undefined > {
692712 const dbItem = await this . getDatabaseItemInternal ( undefined ) ;
693713 return dbItem ?. databaseUri . fsPath ;
Original file line number Diff line number Diff line change @@ -42,6 +42,22 @@ export interface TrimCacheParams {
4242 db : string ;
4343}
4444
45+ /**
46+ * Parameters for trimming the cache of a dataset with a specific mode.
47+ */
48+ export interface TrimCacheWithModeParams {
49+ /**
50+ * The dataset that we want to trim the cache of.
51+ */
52+ db : string ;
53+ /**
54+ * The cache cleanup mode to use.
55+ */
56+ mode : ClearCacheMode ;
57+ }
58+
59+ export type ClearCacheMode = "clear" | "trim" | "fit" | "overlay" ;
60+
4561/**
4662 * The result of trimming or clearing the cache.
4763 */
@@ -193,6 +209,14 @@ export const trimCache = new RequestType<
193209 ClearCacheResult ,
194210 void
195211> ( "evaluation/trimCache" ) ;
212+ /**
213+ * Trim the cache of a dataset with a specific mode.
214+ */
215+ export const trimCacheWithMode = new RequestType <
216+ WithProgressId < TrimCacheWithModeParams > ,
217+ ClearCacheResult ,
218+ void
219+ > ( "evaluation/trimCacheWithMode" ) ;
196220
197221/**
198222 * Clear the pack cache
Original file line number Diff line number Diff line change @@ -6,17 +6,20 @@ import { UserCancellationException } from "../common/vscode/progress";
66import type { DatabaseItem } from "../databases/local-databases/database-item" ;
77import { QueryOutputDir } from "../local-queries/query-output-dir" ;
88import type {
9+ ClearCacheMode ,
910 ClearCacheParams ,
1011 Position ,
1112 QueryResultType ,
1213 TrimCacheParams ,
14+ TrimCacheWithModeParams ,
1315} from "./messages" ;
1416import {
1517 clearCache ,
1618 clearPackCache ,
1719 deregisterDatabases ,
1820 registerDatabases ,
1921 trimCache ,
22+ trimCacheWithMode ,
2023 upgradeDatabase ,
2124} from "./messages" ;
2225import type { BaseLogger , Logger } from "../common/logging" ;
@@ -142,6 +145,22 @@ export class QueryRunner {
142145 await this . qs . sendRequest ( trimCache , params ) ;
143146 }
144147
148+ async trimCacheWithModeInDatabase (
149+ dbItem : DatabaseItem ,
150+ mode : ClearCacheMode ,
151+ ) : Promise < void > {
152+ if ( dbItem . contents === undefined ) {
153+ throw new Error ( "Can't clean the cache in an invalid database." ) ;
154+ }
155+
156+ const db = dbItem . databaseUri . fsPath ;
157+ const params : TrimCacheWithModeParams = {
158+ db,
159+ mode,
160+ } ;
161+ await this . qs . sendRequest ( trimCacheWithMode , params ) ;
162+ }
163+
145164 public async compileAndRunQueryAgainstDatabaseCore (
146165 dbPath : string ,
147166 queries : CoreQueryTarget [ ] ,
You can’t perform that action at this time.
0 commit comments