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

Commit

Permalink
分块上传前这个 promise 在处理过程中,不要让暂停恢复后让 block 发送多个
Browse files Browse the repository at this point in the history
  • Loading branch information
2betop committed Feb 18, 2019
1 parent 32686ce commit 7094e44
Show file tree
Hide file tree
Showing 17 changed files with 91 additions and 21 deletions.
9 changes: 8 additions & 1 deletion dist/webuploader.custom.js
Original file line number Diff line number Diff line change
Expand Up @@ -3692,6 +3692,10 @@
if ( file.getStatus() === Status.INTERRUPT ) {
me._trigged = false;
files.push(file);

if (v.waiting) {
return;
}

// 文件 prepare 完后,如果暂停了,这个时候只会把文件插入 pool, 而不会创建 tranport,
v.transport ? v.transport.send() : me._doSend(v);
Expand Down Expand Up @@ -4062,7 +4066,8 @@
file.source.slice( block.start, block.end );

// hook, 每个分片发送之前可能要做些异步的事情。
promise = me.request( 'before-send', block, function() {
block.waiting = promise = me.request( 'before-send', block, function() {
delete block.waiting;

// 有可能文件已经上传出错了,所以不需要再传输了。
if ( file.getStatus() === Status.PROGRESS ) {
Expand All @@ -4076,6 +4081,8 @@

// 如果为fail了,则跳过此分片。
promise.fail(function() {
delete block.waiting;

if ( file.remaning === 1 ) {
me._finishFile( file ).always(function() {
block.percentage = 1;
Expand Down
4 changes: 2 additions & 2 deletions dist/webuploader.custom.min.js

Large diffs are not rendered by default.

9 changes: 8 additions & 1 deletion dist/webuploader.fis.js
Original file line number Diff line number Diff line change
Expand Up @@ -3566,6 +3566,10 @@ module.exports = (function( root, factory ) {
if ( file.getStatus() === Status.INTERRUPT ) {
me._trigged = false;
files.push(file);

if (v.waiting) {
return;
}

// 文件 prepare 完后,如果暂停了,这个时候只会把文件插入 pool, 而不会创建 tranport,
v.transport ? v.transport.send() : me._doSend(v);
Expand Down Expand Up @@ -3936,7 +3940,8 @@ module.exports = (function( root, factory ) {
file.source.slice( block.start, block.end );

// hook, 每个分片发送之前可能要做些异步的事情。
promise = me.request( 'before-send', block, function() {
block.waiting = promise = me.request( 'before-send', block, function() {
delete block.waiting;

// 有可能文件已经上传出错了,所以不需要再传输了。
if ( file.getStatus() === Status.PROGRESS ) {
Expand All @@ -3950,6 +3955,8 @@ module.exports = (function( root, factory ) {

// 如果为fail了,则跳过此分片。
promise.fail(function() {
delete block.waiting;

if ( file.remaning === 1 ) {
me._finishFile( file ).always(function() {
block.percentage = 1;
Expand Down
9 changes: 8 additions & 1 deletion dist/webuploader.flashonly.js
Original file line number Diff line number Diff line change
Expand Up @@ -3389,6 +3389,10 @@
if ( file.getStatus() === Status.INTERRUPT ) {
me._trigged = false;
files.push(file);

if (v.waiting) {
return;
}

// 文件 prepare 完后,如果暂停了,这个时候只会把文件插入 pool, 而不会创建 tranport,
v.transport ? v.transport.send() : me._doSend(v);
Expand Down Expand Up @@ -3759,7 +3763,8 @@
file.source.slice( block.start, block.end );

// hook, 每个分片发送之前可能要做些异步的事情。
promise = me.request( 'before-send', block, function() {
block.waiting = promise = me.request( 'before-send', block, function() {
delete block.waiting;

// 有可能文件已经上传出错了,所以不需要再传输了。
if ( file.getStatus() === Status.PROGRESS ) {
Expand All @@ -3773,6 +3778,8 @@

// 如果为fail了,则跳过此分片。
promise.fail(function() {
delete block.waiting;

if ( file.remaning === 1 ) {
me._finishFile( file ).always(function() {
block.percentage = 1;
Expand Down
4 changes: 2 additions & 2 deletions dist/webuploader.flashonly.min.js

Large diffs are not rendered by default.

9 changes: 8 additions & 1 deletion dist/webuploader.html5nodepend.js
Original file line number Diff line number Diff line change
Expand Up @@ -4121,6 +4121,10 @@
if ( file.getStatus() === Status.INTERRUPT ) {
me._trigged = false;
files.push(file);

if (v.waiting) {
return;
}

// 文件 prepare 完后,如果暂停了,这个时候只会把文件插入 pool, 而不会创建 tranport,
v.transport ? v.transport.send() : me._doSend(v);
Expand Down Expand Up @@ -4491,7 +4495,8 @@
file.source.slice( block.start, block.end );

// hook, 每个分片发送之前可能要做些异步的事情。
promise = me.request( 'before-send', block, function() {
block.waiting = promise = me.request( 'before-send', block, function() {
delete block.waiting;

// 有可能文件已经上传出错了,所以不需要再传输了。
if ( file.getStatus() === Status.PROGRESS ) {
Expand All @@ -4505,6 +4510,8 @@

// 如果为fail了,则跳过此分片。
promise.fail(function() {
delete block.waiting;

if ( file.remaning === 1 ) {
me._finishFile( file ).always(function() {
block.percentage = 1;
Expand Down
4 changes: 2 additions & 2 deletions dist/webuploader.html5nodepend.min.js

Large diffs are not rendered by default.

9 changes: 8 additions & 1 deletion dist/webuploader.html5only.js
Original file line number Diff line number Diff line change
Expand Up @@ -3591,6 +3591,10 @@
if ( file.getStatus() === Status.INTERRUPT ) {
me._trigged = false;
files.push(file);

if (v.waiting) {
return;
}

// 文件 prepare 完后,如果暂停了,这个时候只会把文件插入 pool, 而不会创建 tranport,
v.transport ? v.transport.send() : me._doSend(v);
Expand Down Expand Up @@ -3961,7 +3965,8 @@
file.source.slice( block.start, block.end );

// hook, 每个分片发送之前可能要做些异步的事情。
promise = me.request( 'before-send', block, function() {
block.waiting = promise = me.request( 'before-send', block, function() {
delete block.waiting;

// 有可能文件已经上传出错了,所以不需要再传输了。
if ( file.getStatus() === Status.PROGRESS ) {
Expand All @@ -3975,6 +3980,8 @@

// 如果为fail了,则跳过此分片。
promise.fail(function() {
delete block.waiting;

if ( file.remaning === 1 ) {
me._finishFile( file ).always(function() {
block.percentage = 1;
Expand Down
2 changes: 1 addition & 1 deletion dist/webuploader.html5only.min.js

Large diffs are not rendered by default.

9 changes: 8 additions & 1 deletion dist/webuploader.js
Original file line number Diff line number Diff line change
Expand Up @@ -3591,6 +3591,10 @@
if ( file.getStatus() === Status.INTERRUPT ) {
me._trigged = false;
files.push(file);

if (v.waiting) {
return;
}

// 文件 prepare 完后,如果暂停了,这个时候只会把文件插入 pool, 而不会创建 tranport,
v.transport ? v.transport.send() : me._doSend(v);
Expand Down Expand Up @@ -3961,7 +3965,8 @@
file.source.slice( block.start, block.end );

// hook, 每个分片发送之前可能要做些异步的事情。
promise = me.request( 'before-send', block, function() {
block.waiting = promise = me.request( 'before-send', block, function() {
delete block.waiting;

// 有可能文件已经上传出错了,所以不需要再传输了。
if ( file.getStatus() === Status.PROGRESS ) {
Expand All @@ -3975,6 +3980,8 @@

// 如果为fail了,则跳过此分片。
promise.fail(function() {
delete block.waiting;

if ( file.remaning === 1 ) {
me._finishFile( file ).always(function() {
block.percentage = 1;
Expand Down
2 changes: 1 addition & 1 deletion dist/webuploader.min.js

Large diffs are not rendered by default.

9 changes: 8 additions & 1 deletion dist/webuploader.noimage.js
Original file line number Diff line number Diff line change
Expand Up @@ -3184,6 +3184,10 @@
if ( file.getStatus() === Status.INTERRUPT ) {
me._trigged = false;
files.push(file);

if (v.waiting) {
return;
}

// 文件 prepare 完后,如果暂停了,这个时候只会把文件插入 pool, 而不会创建 tranport,
v.transport ? v.transport.send() : me._doSend(v);
Expand Down Expand Up @@ -3554,7 +3558,8 @@
file.source.slice( block.start, block.end );

// hook, 每个分片发送之前可能要做些异步的事情。
promise = me.request( 'before-send', block, function() {
block.waiting = promise = me.request( 'before-send', block, function() {
delete block.waiting;

// 有可能文件已经上传出错了,所以不需要再传输了。
if ( file.getStatus() === Status.PROGRESS ) {
Expand All @@ -3568,6 +3573,8 @@

// 如果为fail了,则跳过此分片。
promise.fail(function() {
delete block.waiting;

if ( file.remaning === 1 ) {
me._finishFile( file ).always(function() {
block.percentage = 1;
Expand Down
4 changes: 2 additions & 2 deletions dist/webuploader.noimage.min.js

Large diffs are not rendered by default.

9 changes: 8 additions & 1 deletion dist/webuploader.nolog.js
Original file line number Diff line number Diff line change
Expand Up @@ -3591,6 +3591,10 @@
if ( file.getStatus() === Status.INTERRUPT ) {
me._trigged = false;
files.push(file);

if (v.waiting) {
return;
}

// 文件 prepare 完后,如果暂停了,这个时候只会把文件插入 pool, 而不会创建 tranport,
v.transport ? v.transport.send() : me._doSend(v);
Expand Down Expand Up @@ -3961,7 +3965,8 @@
file.source.slice( block.start, block.end );

// hook, 每个分片发送之前可能要做些异步的事情。
promise = me.request( 'before-send', block, function() {
block.waiting = promise = me.request( 'before-send', block, function() {
delete block.waiting;

// 有可能文件已经上传出错了,所以不需要再传输了。
if ( file.getStatus() === Status.PROGRESS ) {
Expand All @@ -3975,6 +3980,8 @@

// 如果为fail了,则跳过此分片。
promise.fail(function() {
delete block.waiting;

if ( file.remaning === 1 ) {
me._finishFile( file ).always(function() {
block.percentage = 1;
Expand Down
2 changes: 1 addition & 1 deletion dist/webuploader.nolog.min.js

Large diffs are not rendered by default.

9 changes: 8 additions & 1 deletion jekyll/js/webuploader.js
Original file line number Diff line number Diff line change
Expand Up @@ -3591,6 +3591,10 @@
if ( file.getStatus() === Status.INTERRUPT ) {
me._trigged = false;
files.push(file);

if (v.waiting) {
return;
}

// 文件 prepare 完后,如果暂停了,这个时候只会把文件插入 pool, 而不会创建 tranport,
v.transport ? v.transport.send() : me._doSend(v);
Expand Down Expand Up @@ -3961,7 +3965,8 @@
file.source.slice( block.start, block.end );

// hook, 每个分片发送之前可能要做些异步的事情。
promise = me.request( 'before-send', block, function() {
block.waiting = promise = me.request( 'before-send', block, function() {
delete block.waiting;

// 有可能文件已经上传出错了,所以不需要再传输了。
if ( file.getStatus() === Status.PROGRESS ) {
Expand All @@ -3975,6 +3980,8 @@

// 如果为fail了,则跳过此分片。
promise.fail(function() {
delete block.waiting;

if ( file.remaning === 1 ) {
me._finishFile( file ).always(function() {
block.percentage = 1;
Expand Down
9 changes: 8 additions & 1 deletion src/widgets/upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,10 @@ define([
if ( file.getStatus() === Status.INTERRUPT ) {
me._trigged = false;
files.push(file);

if (v.waiting) {
return;
}

// 文件 prepare 完后,如果暂停了,这个时候只会把文件插入 pool, 而不会创建 tranport,
v.transport ? v.transport.send() : me._doSend(v);
Expand Down Expand Up @@ -638,7 +642,8 @@ define([
file.source.slice( block.start, block.end );

// hook, 每个分片发送之前可能要做些异步的事情。
promise = me.request( 'before-send', block, function() {
block.waiting = promise = me.request( 'before-send', block, function() {
delete block.waiting;

// 有可能文件已经上传出错了,所以不需要再传输了。
if ( file.getStatus() === Status.PROGRESS ) {
Expand All @@ -652,6 +657,8 @@ define([

// 如果为fail了,则跳过此分片。
promise.fail(function() {
delete block.waiting;

if ( file.remaning === 1 ) {
me._finishFile( file ).always(function() {
block.percentage = 1;
Expand Down

0 comments on commit 7094e44

Please sign in to comment.