Skip to content

Commit d729a97

Browse files
iclantonclaude
andcommitted
Scope cacheEntryBuffer to its branch, use cloudCacheHit flag
Replace the outer-scoped cacheEntryBuffer (which was only used as a boolean flag at the cache-miss check) with an explicit cloudCacheHit boolean. This scopes the buffer into the else branch and makes the streaming path set the flag consistently too. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 7d80859 commit d729a97

1 file changed

Lines changed: 8 additions & 14 deletions

File tree

libraries/rush-lib/src/logic/buildCache/OperationBuildCache.ts

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -167,21 +167,19 @@ export class OperationBuildCache {
167167

168168
let localCacheEntryPath: string | undefined =
169169
await this._localBuildCacheProvider.tryGetCacheEntryPathByIdAsync(terminal, cacheId);
170-
let cacheEntryBuffer: Buffer | undefined;
170+
let cloudCacheHit: boolean = false;
171171
let updateLocalCacheSuccess: boolean | undefined;
172172
if (!localCacheEntryPath && this._cloudBuildCacheProvider) {
173173
terminal.writeVerboseLine(
174174
'This project was not found in the local build cache. Querying the cloud build cache.'
175175
);
176176

177-
if (
178-
this._useStreamingBuildCache &&
179-
this._cloudBuildCacheProvider.tryGetCacheEntryStreamByIdAsync
180-
) {
177+
if (this._useStreamingBuildCache && this._cloudBuildCacheProvider.tryGetCacheEntryStreamByIdAsync) {
181178
// Use streaming path to avoid loading the entire cache entry into memory
182179
const cacheEntryStream: NodeJS.ReadableStream | undefined =
183180
await this._cloudBuildCacheProvider.tryGetCacheEntryStreamByIdAsync(terminal, cacheId);
184181
if (cacheEntryStream) {
182+
cloudCacheHit = true;
185183
try {
186184
localCacheEntryPath = await this._localBuildCacheProvider.trySetCacheEntryStreamAsync(
187185
terminal,
@@ -195,11 +193,10 @@ export class OperationBuildCache {
195193
}
196194
}
197195
} else {
198-
cacheEntryBuffer = await this._cloudBuildCacheProvider.tryGetCacheEntryBufferByIdAsync(
199-
terminal,
200-
cacheId
201-
);
196+
const cacheEntryBuffer: Buffer | undefined =
197+
await this._cloudBuildCacheProvider.tryGetCacheEntryBufferByIdAsync(terminal, cacheId);
202198
if (cacheEntryBuffer) {
199+
cloudCacheHit = true;
203200
try {
204201
localCacheEntryPath = await this._localBuildCacheProvider.trySetCacheEntryBufferAsync(
205202
terminal,
@@ -215,7 +212,7 @@ export class OperationBuildCache {
215212
}
216213
}
217214

218-
if (!localCacheEntryPath && !cacheEntryBuffer) {
215+
if (!localCacheEntryPath && !cloudCacheHit) {
219216
terminal.writeVerboseLine('This project was not found in the build cache.');
220217
return false;
221218
}
@@ -349,10 +346,7 @@ export class OperationBuildCache {
349346
throw new InternalError('Expected the local cache entry path to be set.');
350347
}
351348

352-
if (
353-
this._useStreamingBuildCache &&
354-
this._cloudBuildCacheProvider.trySetCacheEntryStreamAsync
355-
) {
349+
if (this._useStreamingBuildCache && this._cloudBuildCacheProvider.trySetCacheEntryStreamAsync) {
356350
// Use streaming upload to avoid loading the entire cache entry into memory
357351
const entryStream: FileSystemReadStream = FileSystem.createReadStream(localCacheEntryPath);
358352
setCloudCacheEntryPromise = this._cloudBuildCacheProvider

0 commit comments

Comments
 (0)