Skip to content
This repository has been archived by the owner on Aug 22, 2022. It is now read-only.

Commit

Permalink
fix #488
Browse files Browse the repository at this point in the history
  • Loading branch information
2betop committed Sep 22, 2014
1 parent a705b27 commit b7333c2
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions src/widgets/upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ define([
this.__tick = Base.bindFn( this._tick, this );

owner.on( 'uploadComplete', function( file ) {

// 把其他块取消了。
file.blocks && $.each( file.blocks, function( _, v ) {
v.transport && (v.transport.abort(), v.transport.destroy());
Expand Down Expand Up @@ -222,15 +222,15 @@ define([

if (file.getStatus() === Status.INTERRUPT) {
$.each( me.pool, function( _, v ) {

// 之前暂停过。
if (v.file !== file) {
return;
}

v.transport && v.transport.send();
});

file.setStatus( Status.QUEUED );
} else if (file.getStatus() === Status.PROGRESS) {
return;
Expand All @@ -249,17 +249,24 @@ define([

me.runing = true;

var files = [];

// 如果有暂停的,则续传
$.each( me.pool, function( _, v ) {
var file = v.file;

if ( file.getStatus() === Status.INTERRUPT ) {
file.setStatus( Status.PROGRESS );
files.push(file);
me._trigged = false;
v.transport && v.transport.send();
}
});

var file;
while ( (file = files.shift()) ) {
file.setStatus( Status.PROGRESS );
}

file || $.each( me.request( 'get-files',
Status.INTERRUPT ), function() {
this.setStatus( Status.PROGRESS );
Expand Down Expand Up @@ -309,7 +316,7 @@ define([

file.setStatus( Status.INTERRUPT );
$.each( me.pool, function( _, v ) {

// 只 abort 指定的文件。
if (v.file !== file) {
return;
Expand Down Expand Up @@ -508,7 +515,7 @@ define([
if ( !file ) {
return null;
}

act = CuteFile( file, opts.chunked ? opts.chunkSize : 0 );
me.stack.push(act);
return act.shift();
Expand Down Expand Up @@ -543,7 +550,7 @@ define([
promise = me.request( 'before-send-file', file, function() {

// 有可能文件被skip掉了。文件被skip掉后,状态坑定不是Queued.
if ( file.getStatus() === Status.PROGRESS ||
if ( file.getStatus() === Status.PROGRESS ||
file.getStatus() === Status.INTERRUPT ) {
return file;
}
Expand Down Expand Up @@ -593,7 +600,7 @@ define([
// 如:暂停,取消
// 我们不能中断 promise, 但是可以在 promise 完后,不做上传操作。
if ( file.getStatus() !== Status.PROGRESS ) {

// 如果是中断,则还需要放回去。
if (file.getStatus() === Status.INTERRUPT) {
me._putback(block);
Expand Down

0 comments on commit b7333c2

Please sign in to comment.