Skip to content

Commit 0a77f3d

Browse files
committed
append
1 parent 2ac7357 commit 0a77f3d

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ qiniu.compressImage(file, options).then(data => {
171171
* ProgressCompose 的信息如下
172172
* size: `number` chunk 的尺寸
173173
* loaded: `number` 已经发送完毕的尺寸
174-
* percent: `number` 进度比例,范围在 0 - 1
174+
* percent: `number` 进度比例,范围在 0 - 100
175175
* isCache?: `boolean` 是否使用的缓存
176176
* total: 包含 `loaded``total``percent` 三个属性:
177177
* total.loaded: `number`,已上传大小,单位为字节。
@@ -184,7 +184,7 @@ qiniu.compressImage(file, options).then(data => {
184184
* message: `string` 错误的信息。
185185
* stack: `string` 调用堆栈信息。
186186
* `QiniuRequestError` 继承自 `QiniuError`
187-
* data: `{[key:string]:any}` 服务端返回的错误信息,如果不是一个标准的 `json` 格式,则该字段为 `undefined`
187+
* data: `any` 服务端返回的错误信息,如果不是一个标准的 `json` 格式,则该字段为 `undefined`
188188
* reqId: `string` xhr 请求错误的 `X-Reqid`
189189
* code: `number` 请求错误状态码,可查阅码值对应 [说明](https://developer.qiniu.com/kodo/api/3928/error-responses)。
190190
* isRequestError: 固定为 `true`*不推荐使用,即将废弃*

src/errors/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ export class QiniuRequestError extends QiniuError {
4545
/**
4646
* @description 发生错误时服务端返回的错误信息,如果返回不是一个合法的 json、则该字段为 undefined
4747
*/
48-
public data?: { [key: string]: any }
48+
public data?: any
4949

50-
constructor(public code: number, public reqId: string, message: string, data?: { [key: string]: any }) {
50+
constructor(public code: number, public reqId: string, message: string, data?: any) {
5151
super(QiniuErrorName.RequestError, message)
5252
this.data = data
5353
}

src/upload/resume.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import Base, { Progress, UploadInfo, Extra } from './base'
66

77
export interface UploadedChunkStorage extends UploadChunkData {
88
size: number
9+
10+
isCache?: boolean
911
}
1012

1113
export interface ChunkLoaded {
@@ -103,7 +105,7 @@ export default class Resume extends Base {
103105

104106
const shouldCheckMD5 = this.config.checkByMD5
105107
const reuseSaved = () => {
106-
this.usedCaches.push(index)
108+
info.isCache = true
107109
this.updateChunkProgress(chunk.size, index)
108110
}
109111

@@ -248,10 +250,12 @@ export default class Resume extends Base {
248250
this.progress = {
249251
total: this.getProgressInfoItem(
250252
utils.sum(this.loaded.chunks) + this.loaded.mkFileProgress,
253+
// FIXME: 不准确的 fileSize
251254
this.file.size + 1 // 防止在 complete 未调用的时候进度显示 100%
252255
),
253256
chunks: this.chunks.map((chunk, index) => {
254-
const isCache = this.usedCaches.includes(index)
257+
const info = this.uploadedList[index]
258+
const isCache = info && info.isCache
255259
return this.getProgressInfoItem(this.loaded.chunks[index], chunk.size, isCache)
256260
}),
257261
uploadInfo: {

0 commit comments

Comments
 (0)