@@ -5,17 +5,20 @@ import { AnalysisKind } from "./analyses";
55import { getApiClient , GitHubApiDetails } from "./api-client" ;
66import { type CodeQL } from "./codeql" ;
77import { Config } from "./config-utils" ;
8+ import { Feature , FeatureEnablement } from "./feature-flags" ;
89import * as gitUtils from "./git-utils" ;
910import { Logger , withGroupAsync } from "./logging" ;
11+ import { OverlayDatabaseMode } from "./overlay-database-utils" ;
1012import { RepositoryNwo } from "./repository" ;
1113import * as util from "./util" ;
12- import { bundleDb , parseGitHubUrl } from "./util" ;
14+ import { bundleDb , CleanupLevel , parseGitHubUrl } from "./util" ;
1315
1416export async function cleanupAndUploadDatabases (
1517 repositoryNwo : RepositoryNwo ,
1618 codeql : CodeQL ,
1719 config : Config ,
1820 apiDetails : GitHubApiDetails ,
21+ features : FeatureEnablement ,
1922 logger : Logger ,
2023) : Promise < void > {
2124 if ( actionsUtil . getRequiredInput ( "upload-database" ) !== "true" ) {
@@ -50,10 +53,16 @@ export async function cleanupAndUploadDatabases(
5053 return ;
5154 }
5255
56+ const cleanupLevel =
57+ config . overlayDatabaseMode === OverlayDatabaseMode . OverlayBase &&
58+ ( await features . getValue ( Feature . UploadOverlayDbToApi ) )
59+ ? CleanupLevel . Overlay
60+ : CleanupLevel . Clear ;
61+
5362 // Clean up the database, since intermediate results may still be written to the
5463 // database if there is high RAM pressure.
5564 await withGroupAsync ( "Cleaning up databases" , async ( ) => {
56- await codeql . databaseCleanupCluster ( config , "clear" ) ;
65+ await codeql . databaseCleanupCluster ( config , cleanupLevel ) ;
5766 } ) ;
5867
5968 const client = getApiClient ( ) ;
0 commit comments