@@ -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.
@@ -169,14 +194,12 @@ export async function uploadOverlayBaseDatabaseToCache(
169
194
return false ;
170
195
}
171
196
172
- // An overlay-base database should contain the base database OIDs file.
173
- // Verifying that the file exists serves as a sanity check.
174
- const baseDatabaseOidsFilePath = getBaseDatabaseOidsFilePath ( config ) ;
175
- if ( ! fs . existsSync ( baseDatabaseOidsFilePath ) ) {
176
- logger . warning (
177
- "Cannot upload overlay-base database to cache: " +
178
- `${ baseDatabaseOidsFilePath } does not exist` ,
179
- ) ;
197
+ const databaseIsValid = checkOverlayBaseDatabase (
198
+ config ,
199
+ logger ,
200
+ "Abort uploading overlay-base database to cache" ,
201
+ ) ;
202
+ if ( ! databaseIsValid ) {
180
203
return false ;
181
204
}
182
205
0 commit comments