@@ -132,6 +132,31 @@ const CACHE_VERSION = 1;
132
132
const CACHE_PREFIX = "codeql-overlay-base-database" ;
133
133
const MAX_CACHE_OPERATION_MS = 120_000 ; // Two minutes
134
134
135
+ /**
136
+ * Checks that the overlay-base database is valid by checking for the
137
+ * existence of the base database OIDs file.
138
+ *
139
+ * @param config The configuration object
140
+ * @param logger The logger instance
141
+ * @param warningPrefix Prefix for the check failure warning message
142
+ * @returns True if the verification succeeded, false otherwise
143
+ */
144
+ export function checkOverlayBaseDatabase (
145
+ config : Config ,
146
+ logger : Logger ,
147
+ warningPrefix : string ,
148
+ ) : boolean {
149
+ // An overlay-base database should contain the base database OIDs file.
150
+ const baseDatabaseOidsFilePath = getBaseDatabaseOidsFilePath ( config ) ;
151
+ if ( ! fs . existsSync ( baseDatabaseOidsFilePath ) ) {
152
+ logger . warning (
153
+ `${ warningPrefix } : ${ baseDatabaseOidsFilePath } does not exist` ,
154
+ ) ;
155
+ return false ;
156
+ }
157
+ return true ;
158
+ }
159
+
135
160
/**
136
161
* Uploads the overlay-base database to the GitHub Actions cache. If conditions
137
162
* for uploading are not met, the function does nothing and returns false.
@@ -172,14 +197,12 @@ export async function uploadOverlayBaseDatabaseToCache(
172
197
return false ;
173
198
}
174
199
175
- // An overlay-base database should contain the base database OIDs file.
176
- // Verifying that the file exists serves as a sanity check.
177
- const baseDatabaseOidsFilePath = getBaseDatabaseOidsFilePath ( config ) ;
178
- if ( ! fs . existsSync ( baseDatabaseOidsFilePath ) ) {
179
- logger . warning (
180
- "Cannot upload overlay-base database to cache: " +
181
- `${ baseDatabaseOidsFilePath } does not exist` ,
182
- ) ;
200
+ const databaseIsValid = checkOverlayBaseDatabase (
201
+ config ,
202
+ logger ,
203
+ "Abort uploading overlay-base database to cache" ,
204
+ ) ;
205
+ if ( ! databaseIsValid ) {
183
206
return false ;
184
207
}
185
208
0 commit comments