Skip to content

Commit 3dc0a05

Browse files
FS-10615: Unit test issues fixed (#512)
* Increase the chunks size to upload the max file size * Chunk size and chunk count calculation updated for files greater than 60GB for default case and 80GB for intelligent ingestion * Default values re-stored * Unit test issues fixed * Unit test fixed for chunk size and parts count --------- Co-authored-by: Prem Verma <premprakash.v@celestialsys.com>
1 parent b2fc08d commit 3dc0a05

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

src/lib/api/upload/file.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ describe('Api/Upload/File', () => {
7373
});
7474

7575
it('should return correct parts count for given size', () => {
76-
expect(file.getPartsCount(1)).toEqual(file.size);
76+
expect(file.getPartsCount(1)).toEqual({ chunkSize: 1, partsCount: 4 });
7777
});
7878

7979
it('should return correct part metadata', () => {

src/lib/api/upload/file.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ export interface FileChunk extends FilePart {
5353
}
5454

5555
export interface PartSize {
56-
partsCount: number,
57-
chunkSize: number
56+
partsCount: number;
57+
chunkSize: number;
5858
}
5959

6060
/**
@@ -171,31 +171,31 @@ export class File {
171171
/**
172172
* Returns number of parts and part size according to max limit
173173
* @param {number} size - part size in bytes
174-
* @returns {PartSize}
174+
* @returns {PartSize}
175175
* @memberof File
176176
*/
177177
public getPartsCount (size: number, intelligentChunk: boolean): PartSize {
178-
const DEFAULT_FILE_SIZE_LIMIT = 60 * 1024 * 1024 * 1024
179-
const INTELLIGENT_FILE_SIZE_LIMIT = 80 * 1024 * 1024 * 1024
178+
const DEFAULT_FILE_SIZE_LIMIT = 60 * 1024 * 1024 * 1024;
179+
const INTELLIGENT_FILE_SIZE_LIMIT = 80 * 1024 * 1024 * 1024;
180180
const FILE_SIZE_LIMIT = intelligentChunk ? INTELLIGENT_FILE_SIZE_LIMIT : DEFAULT_FILE_SIZE_LIMIT;
181181
const MAX_S3_CHUNKS_ALLOWED = 10000;
182-
182+
183183
// When file size is greater than 60GB, chunk size is calculated dynamically
184184
// Chunk count is set to the max number of chunks allowed over s3
185-
if(this._file.size > FILE_SIZE_LIMIT) {
185+
if (this._file.size > FILE_SIZE_LIMIT) {
186186
const dynamicPartSize = Math.ceil(this._file.size / MAX_S3_CHUNKS_ALLOWED); // size is set in bytes
187187

188188
return {
189189
partsCount: Math.ceil(this._file.size / dynamicPartSize),
190-
chunkSize: dynamicPartSize
191-
}
190+
chunkSize: dynamicPartSize,
191+
};
192192

193193
}
194194

195195
return {
196196
partsCount: Math.ceil(this._file.size / size),
197-
chunkSize: size
198-
}
197+
chunkSize: size,
198+
};
199199
}
200200

201201
/**

0 commit comments

Comments
 (0)