Skip to content

Commit 0a16941

Browse files
committed
refactor: Integrity handling
getIntegrity tests still need to be updated
1 parent a60fb8a commit 0a16941

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

packages/fs/lib/Resource.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -554,15 +554,15 @@ class Resource {
554554

555555
switch (this.#contentType) {
556556
case CONTENT_TYPES.BUFFER:
557-
this.#integrity = ssri.fromData(this.#content, SSRI_OPTIONS);
557+
this.#integrity = ssri.fromData(this.#content, SSRI_OPTIONS).toString();
558558
break;
559559
case CONTENT_TYPES.FACTORY:
560-
this.#integrity = await ssri.fromStream(this.#createStreamFactory(), SSRI_OPTIONS);
560+
this.#integrity = (await ssri.fromStream(this.#createStreamFactory(), SSRI_OPTIONS)).toString();
561561
break;
562562
case CONTENT_TYPES.STREAM:
563563
// To be discussed: Should we read the stream into a buffer here (using #getBufferFromStream) to avoid
564564
// draining it?
565-
this.#integrity = ssri.fromData(await this.#getBufferFromStream(this.#content), SSRI_OPTIONS);
565+
this.#integrity = ssri.fromData(await this.#getBufferFromStream(this.#content), SSRI_OPTIONS).toString();
566566
break;
567567
case CONTENT_TYPES.DRAINED_STREAM:
568568
throw new Error(`Unexpected error: Content of Resource ${this.#path} is flagged as drained.`);

packages/project/lib/build/cache/CacheManager.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,10 @@ export default class CacheManager {
8787
log.info(`Integrity mismatch for cache entry ` +
8888
`${cacheKey}: expected ${integrity}, got ${result.integrity}`);
8989

90-
const res = await cacache.get.byDigest(this.#casDir, result.integrity);
90+
const res = await cacache.get.byDigest(this.#casDir, integrity);
9191
if (res) {
9292
log.info(`Updating cache entry with expectation...`);
93-
await this.writeStage(buildSignature, stageId, resourcePath, res.data);
93+
await this.writeStage(buildSignature, stageId, resourcePath, res);
9494
return await this.getResourcePathForStage(buildSignature, stageId, resourcePath, integrity);
9595
}
9696
}

0 commit comments

Comments
 (0)