@@ -51,6 +51,10 @@ const CODEQL_DEFAULT_CACHE_CONFIG: { [language: string]: CacheConfig } = {
51
51
} ,
52
52
} ;
53
53
54
+ async function makeGlobber ( files : string [ ] ) : Promise < glob . Globber > {
55
+ return glob . create ( files . join ( "\n" ) ) ;
56
+ }
57
+
54
58
/**
55
59
* Attempts to restore dependency caches for the languages being analyzed.
56
60
*
@@ -74,6 +78,17 @@ export async function downloadDependencyCaches(
74
78
continue ;
75
79
}
76
80
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
+
77
92
const primaryKey = await cacheKey ( language , cacheConfig ) ;
78
93
const restoreKeys : string [ ] = [ await cachePrefix ( language ) ] ;
79
94
@@ -115,9 +130,18 @@ export async function uploadDependencyCaches(config: Config, logger: Logger) {
115
130
continue ;
116
131
}
117
132
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
+ }
120
143
144
+ const size = await getTotalCacheSize ( cacheConfig . paths , logger ) ;
121
145
const key = await cacheKey ( language , cacheConfig ) ;
122
146
123
147
logger . info (
0 commit comments