Skip to content

Commit

Permalink
fixed #1280
Browse files Browse the repository at this point in the history
  • Loading branch information
Danial Farid authored and Danial Farid committed Jan 17, 2016
1 parent 1db5c2f commit 0ae00fb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/drop.js
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@
$q.all(promises).then(function () {
if (!multiple) {
var i = 0;
while (files[i].type === 'directory') i++;
while (files.length && files[i].type === 'directory') i++;

This comment has been minimized.

Copy link
@ruslan5t

ruslan5t Jan 28, 2016

Imagine this situation: files.length = 1, this row will throw error when variable 'i' will became equal to 1. It is a critical bug!

This comment has been minimized.

Copy link
@danialfarid

danialfarid Jan 28, 2016

Owner

Thanks for finding this out. Will be fixed in the next release. This is a very rare case that you don't have multiple and you have allow-dir and you drop a single directory with no files inside, You will get an error and no file will be uploaded but the behaviour is expected since there is no file dropped so nothing is there to be uploaded, but the error should not show up.

This comment has been minimized.

Copy link
@ruslan5t

ruslan5t Jan 29, 2016

You are welcome and thanks for fixing it in next version!

defer.resolve([files[i]]);
} else {
defer.resolve(files);
Expand Down
11 changes: 4 additions & 7 deletions src/upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ ngFileUpload.version = '<%= pkg.version %>';

ngFileUpload.service('UploadBase', ['$http', '$q', '$timeout', function ($http, $q, $timeout) {
var upload = this;
upload.promises = [];
upload.promisesCount = 0;

this.isResumeSupported = function () {
return window.Blob && (window.Blob instanceof Function) && new window.Blob().slice;
Expand Down Expand Up @@ -172,18 +172,15 @@ ngFileUpload.service('UploadBase', ['$http', '$q', '$timeout', function ($http,
return promise;
};

upload.promises.push(promise);
upload.promisesCount++;
promise['finally'](function () {
var i = upload.promises.indexOf(promise);
if (i > -1) {
upload.promises.splice(i, 1);
}
upload.promisesCount--;
});
return promise;
}

this.isUploadInProgress = function() {
return upload.promises.length > 0;
return upload.promisesCount > 0;
};

this.rename = function (file, name) {
Expand Down

0 comments on commit 0ae00fb

Please sign in to comment.