Skip to content

Commit 94e349d

Browse files
authored
[BUG] 修复 initBeforeUploadChunks 错误未中断的行为 (#503)
1 parent 2cfc5ed commit 94e349d

File tree

3 files changed

+10
-15
lines changed

3 files changed

+10
-15
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "qiniu-js",
33
"jsName": "qiniu",
4-
"version": "3.1.3",
4+
"version": "3.1.4",
55
"private": false,
66
"description": "Javascript SDK for Qiniu Resource (Cloud) Storage AP",
77
"main": "lib/index.js",

src/upload/resume.ts

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -45,26 +45,21 @@ export default class Resume extends Base {
4545
private loaded: ChunkLoaded
4646
private uploadId: string
4747

48+
/**
49+
* @returns {Promise<ResponseSuccess<any>>}
50+
* @description 实现了 Base 的 run 接口,处理具体的分片上传事务,并抛出过程中的异常。
51+
*/
4852
protected async run() {
4953
this.logger.info('start run Resume.')
5054
if (!this.config.chunkSize || !isPositiveInteger(this.config.chunkSize)) {
51-
const errorMessage = 'chunkSize must be a positive integer.'
52-
this.logger.error(errorMessage)
53-
throw new Error(errorMessage)
55+
throw new Error('chunkSize must be a positive integer.')
5456
}
5557

5658
if (this.config.chunkSize > 1024) {
57-
const errorMessage = 'chunkSize maximum value is 1024.'
58-
this.logger.error(errorMessage)
59-
throw new Error(errorMessage)
59+
throw new Error('chunkSize maximum value is 1024.')
6060
}
6161

62-
try {
63-
await this.initBeforeUploadChunks()
64-
} catch (error) {
65-
const errorMessage = 'initBeforeUploadChunks failed.'
66-
this.logger.warn(errorMessage, error)
67-
}
62+
await this.initBeforeUploadChunks()
6863

6964
const pool = new Pool(
7065
(chunkInfo: ChunkInfo) => this.uploadChunk(chunkInfo),

0 commit comments

Comments
 (0)