Skip to content

Commit 7a6eea5

Browse files
committed
Added: tweaks after PR review (progress round, strict equality)
1 parent bc437b0 commit 7a6eea5

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

src/files/infra/clients/DirectUploadClient.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ export class DirectUploadClient implements IDirectUploadClient {
2626
private readonly progressAfterUrlGeneration: number = 10
2727
private readonly progressAfterFileUpload: number = 100
2828

29+
private readonly fileUploadTimeoutMs: number = 60_000
30+
2931
constructor(filesRepository: IFilesRepository, maxMultipartRetries = 5) {
3032
this.filesRepository = filesRepository
3133
this.maxMultipartRetries = maxMultipartRetries
@@ -38,7 +40,7 @@ export class DirectUploadClient implements IDirectUploadClient {
3840
abortController: AbortController,
3941
destination?: FileUploadDestination
4042
): Promise<string> {
41-
if (destination == undefined) {
43+
if (destination === undefined) {
4244
destination = await this.filesRepository
4345
.getFileUploadDestination(datasetId, file)
4446
.catch((error) => {
@@ -71,7 +73,7 @@ export class DirectUploadClient implements IDirectUploadClient {
7173
'Content-Length': file.size.toString(),
7274
'x-amz-tagging': 'dv-state=temp'
7375
},
74-
timeout: 60000,
76+
timeout: this.fileUploadTimeoutMs,
7577
signal: abortController.signal
7678
})
7779
} catch (error) {
@@ -113,12 +115,12 @@ export class DirectUploadClient implements IDirectUploadClient {
113115
},
114116
maxBodyLength: Infinity,
115117
maxContentLength: Infinity,
116-
timeout: 60000,
118+
timeout: this.fileUploadTimeoutMs,
117119
signal: abortController.signal
118120
})
119121
const eTag = response.headers['etag'].replace(/"/g, '')
120122
eTags[`${index + 1}`] = eTag
121-
progress(this.progressAfterUrlGeneration + progressPartSize * (index + 1))
123+
progress(Math.round(this.progressAfterUrlGeneration + progressPartSize * (index + 1)))
122124
} catch (error) {
123125
if (axios.isCancel(error)) {
124126
await this.abortMultipartUpload(file.name, datasetId, destination.abortEndpoint)

src/files/infra/repositories/transformers/fileUploadDestinationsTransformers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export const transformUploadDestinationsResponseToUploadDestination = (
2020
): FileUploadDestination => {
2121
const fileUploadDestinationsPayload = response.data.data
2222

23-
if (fileUploadDestinationsPayload.url != undefined) {
23+
if (fileUploadDestinationsPayload.url !== undefined) {
2424
return {
2525
urls: [fileUploadDestinationsPayload.url],
2626
partSize: fileUploadDestinationsPayload.partSize,

0 commit comments

Comments
 (0)