Skip to content

Commit

Permalink
Fix cache of credential cache ID.
Browse files Browse the repository at this point in the history
  • Loading branch information
iclanton committed Mar 10, 2021
1 parent b6b6611 commit 152e2ea
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
14 changes: 10 additions & 4 deletions apps/rush-lib/src/logic/buildCache/AmazonS3BuildCacheProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export class AmazonS3BuildCacheProvider extends CloudBuildCacheProviderBase {
private readonly _s3Prefix: string | undefined;
private readonly _environmentWriteCredential: string | undefined;
private readonly _isCacheWriteAllowedByConfiguration: boolean;
private __credentialCacheId: string | undefined;

public get isCacheWriteAllowed(): boolean {
return this._isCacheWriteAllowedByConfiguration || !!this._environmentWriteCredential;
Expand Down Expand Up @@ -63,12 +64,17 @@ export class AmazonS3BuildCacheProvider extends CloudBuildCacheProviderBase {
}

private get _credentialCacheId(): string {
const cacheIdParts: string[] = ['aws-s3', this._s3Region, this._s3Bucket];
if (!this.__credentialCacheId) {
const cacheIdParts: string[] = ['aws-s3', this._s3Region, this._s3Bucket];

if (this._isCacheWriteAllowedByConfiguration) {
cacheIdParts.push('cacheWriteAllowed');
if (this._isCacheWriteAllowedByConfiguration) {
cacheIdParts.push('cacheWriteAllowed');
}

this.__credentialCacheId = cacheIdParts.join('|');
}
return cacheIdParts.join('|');

return this.__credentialCacheId;
}

private async _getS3ClientAsync(): Promise<S3Client> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export class AzureStorageBuildCacheProvider extends CloudBuildCacheProviderBase
cacheIdParts.push('cacheWriteAllowed');
}

return cacheIdParts.join('|');
this.__credentialCacheId = cacheIdParts.join('|');
}

return this.__credentialCacheId;
Expand Down

0 comments on commit 152e2ea

Please sign in to comment.