Skip to content

Commit

Permalink
🔥 Remove explicit content-length (#255)
Browse files Browse the repository at this point in the history
This is unused and inaccurate
  • Loading branch information
dmihalcik-virtru authored Nov 15, 2023
1 parent 6e5aaca commit 3224391
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 47 deletions.
2 changes: 0 additions & 2 deletions lib/tdf3/src/client/DecoratedReadableStream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ export class DecoratedReadableStream {
on: EventEmitter['on'];
emit: EventEmitter['emit'];
metadata?: Metadata;
contentLength?: number;
manifest: Manifest;
upsertResponse?: UpsertResponse;
fileStreamServiceWorker?: string;
Expand Down Expand Up @@ -110,7 +109,6 @@ export class DecoratedReadableStream {
}

const fileStream = streamSaver.createWriteStream(filepath, {
...(this.contentLength && { size: this.contentLength }),
writableStrategy: { highWaterMark: 1 },
readableStrategy: { highWaterMark: 1 },
});
Expand Down
24 changes: 2 additions & 22 deletions lib/tdf3/src/client/builders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ export type EncryptParams = {
scope?: Scope;
metadata?: Metadata;
keypair?: CryptoKeyPair;
contentLength?: number;
offline?: boolean;
windowSize?: number;
asHtml?: boolean;
Expand Down Expand Up @@ -74,15 +73,6 @@ class EncryptParamsBuilder {
this._params = { ...params };
}

setContentLength(contentLength: number) {
this._params.contentLength = contentLength;
}

withContentLength(contentLength: number) {
this.setContentLength(contentLength);
return this;
}

getStreamSource(): EncryptParams['source'] | undefined {
return this._params.source;
}
Expand Down Expand Up @@ -485,12 +475,11 @@ export type DecryptSource =
| { type: 'file-browser'; location: Blob };

export type DecryptParams = {
source: DecryptSource;
opts?: { keypair: PemKeyPair };
eo?: EntityObject;
source: DecryptSource;
keyMiddleware?: DecryptKeyMiddleware;
streamMiddleware?: DecryptStreamMiddleware;
} & Pick<EncryptParams, 'contentLength' | 'keypair'>;
};

/**
* A builder capable of constructing the necessary parameters object for a
Expand Down Expand Up @@ -518,15 +507,6 @@ class DecryptParamsBuilder {
};
}

setContentLength(contentLength: number) {
this._params.contentLength = contentLength;
}

withContentLength(contentLength: number) {
this.setContentLength(contentLength);
return this;
}

getStreamSource(): DecryptSource | undefined {
return this._params.source;
}
Expand Down
2 changes: 1 addition & 1 deletion remote-store/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 0 additions & 14 deletions remote-store/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {
S3Client,
GetObjectCommand,
HeadObjectCommand,
S3ClientConfig,
AbortMultipartUploadCommandOutput,
CompleteMultipartUploadCommandOutput,
Expand Down Expand Up @@ -93,19 +92,6 @@ export const setRemoteStoreAsStream = async (

const s3 = new S3Client(storageParams);

const s3Metadata = await s3.send(
new HeadObjectCommand({
Key: FILE_NAME,
Bucket: BUCKET_NAME,
})
);

if (typeof s3Metadata.ContentLength === 'number') {
if ((builder as DecryptParamsBuilder).setContentLength) {
(builder as DecryptParamsBuilder).setContentLength(s3Metadata.ContentLength);
}
}

const s3download = await s3.send(
new GetObjectCommand({
Key: FILE_NAME,
Expand Down
16 changes: 8 additions & 8 deletions web-app/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 3224391

Please sign in to comment.