Skip to content

Commit b1b6249

Browse files
committed
Merge pull request #51 from qiniu/fix_file_resume_chunk_upload_bug
check file size when resume upload
2 parents 6614fa9 + f16a04e commit b1b6249

File tree

3 files changed

+21
-11
lines changed

3 files changed

+21
-11
lines changed

demo/js/qiniu.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -391,12 +391,17 @@ function QiniuJsSDK() {
391391
var aDay = 24 * 60 * 60 * 1000; // milliseconds
392392
if (now - before < aDay) {
393393
if (localFileInfo.percent !== 100) {
394-
file.percent = localFileInfo.percent;
395-
file.loaded = localFileInfo.offset;
396-
ctx = localFileInfo.ctx;
397-
if (localFileInfo.offset + blockSize > file.size) {
398-
blockSize = file.size - localFileInfo.offset;
394+
if (file.size === localStorage.total) {
395+
file.percent = localFileInfo.percent;
396+
file.loaded = localFileInfo.offset;
397+
ctx = localFileInfo.ctx;
398+
if (localFileInfo.offset + blockSize > file.size) {
399+
blockSize = file.size - localFileInfo.offset;
400+
}
401+
} else {
402+
localStorage.removeItem(file.name);
399403
}
404+
400405
} else {
401406
// 进度100%时,删除对应的localStorage,避免 499 bug
402407
localStorage.removeItem(file.name);

src/qiniu.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -391,12 +391,17 @@ function QiniuJsSDK() {
391391
var aDay = 24 * 60 * 60 * 1000; // milliseconds
392392
if (now - before < aDay) {
393393
if (localFileInfo.percent !== 100) {
394-
file.percent = localFileInfo.percent;
395-
file.loaded = localFileInfo.offset;
396-
ctx = localFileInfo.ctx;
397-
if (localFileInfo.offset + blockSize > file.size) {
398-
blockSize = file.size - localFileInfo.offset;
394+
if (file.size === localStorage.total) {
395+
file.percent = localFileInfo.percent;
396+
file.loaded = localFileInfo.offset;
397+
ctx = localFileInfo.ctx;
398+
if (localFileInfo.offset + blockSize > file.size) {
399+
blockSize = file.size - localFileInfo.offset;
400+
}
401+
} else {
402+
localStorage.removeItem(file.name);
399403
}
404+
400405
} else {
401406
// 进度100%时,删除对应的localStorage,避免 499 bug
402407
localStorage.removeItem(file.name);

0 commit comments

Comments
 (0)