@@ -51,6 +51,10 @@ const CODEQL_DEFAULT_CACHE_CONFIG: { [language: string]: CacheConfig } = {
5151 } ,
5252} ;
5353
54+ async function makeGlobber ( files : string [ ] ) : Promise < glob . Globber > {
55+ return glob . create ( files . join ( "\n" ) ) ;
56+ }
57+
5458/**
5559 * Attempts to restore dependency caches for the languages being analyzed.
5660 *
@@ -74,6 +78,17 @@ export async function downloadDependencyCaches(
7478 continue ;
7579 }
7680
81+ // Check that we can find files to calculate the hash for the cache key from, so we don't end up
82+ // with an empty string.
83+ const globber = await makeGlobber ( cacheConfig . hash ) ;
84+
85+ if ( ( await globber . glob ( ) ) . length === 0 ) {
86+ logger . info (
87+ `Skipping download of dependency cache for ${ language } as we cannot calculate a hash for the cache key.` ,
88+ ) ;
89+ continue ;
90+ }
91+
7792 const primaryKey = await cacheKey ( language , cacheConfig ) ;
7893 const restoreKeys : string [ ] = [ await cachePrefix ( language ) ] ;
7994
@@ -115,9 +130,18 @@ export async function uploadDependencyCaches(config: Config, logger: Logger) {
115130 continue ;
116131 }
117132
118- const globber = await glob . create ( cacheConfig . hash . join ( "\n" ) ) ;
119- const size = await getTotalCacheSize ( await globber . glob ( ) , logger ) ;
133+ // Check that we can find files to calculate the hash for the cache key from, so we don't end up
134+ // with an empty string.
135+ const globber = await makeGlobber ( cacheConfig . hash ) ;
136+
137+ if ( ( await globber . glob ( ) ) . length === 0 ) {
138+ logger . info (
139+ `Skipping upload of dependency cache for ${ language } as we cannot calculate a hash for the cache key.` ,
140+ ) ;
141+ continue ;
142+ }
120143
144+ const size = await getTotalCacheSize ( cacheConfig . paths , logger ) ;
121145 const key = await cacheKey ( language , cacheConfig ) ;
122146
123147 logger . info (
0 commit comments