ivan-novakov / extjs-upload-widget

File upload widget for ExtJS v4
81 stars 42 forks source link

Uploading mulitiple files and synchronous: false #19

Closed middlebrain closed 10 years ago

middlebrain commented 10 years ago

Thank you for writing and sharing this great upload widget. It is a pleasure to read and learn from your code.

While playing around I have found a bug in the function Queue.js -> isLast(). In the asynchronous mode, the callback order ist mostly different from the request order. Therefore you can't finish the upload, if the last queue entry is calling back. I think to finish the upload you need a callback counter, which you have to compare with the number of entries in the queue or with the number of requests.

Here the result of this bug in firebug:

TypeError: this.currentQueue is null

Manager.js: line 177:
if ( this.currentQueue.isLast(item) ) {
ivan-novakov commented 10 years ago

Thanks for the report, I'll have a look at that. I'm not using the asynchronous upload, so I haven't tested it well.

ivan-novakov commented 10 years ago

The bug can be reproduced by selecting a big file first and then a smaller one.

ivan-novakov commented 10 years ago

Added a quick fix to the devel branch. Now during asynchronous upload after each finished upload instead of calling isLast(), the new method existUploadingItems() is called. It checks, if there are any active uploads by going through the queue items. There may be a way how to optimize that, but in case you don't upload hundreds files at once, that should be ok.

Please, test it if you have time.

P. S. I also added a checkbox to toggle synchronouse/asyhcnronous upload in the demo.

middlebrain commented 10 years ago

Wow, you are fast.

I have tested the asynchronous upload with your fix and it is working without problems now. Thanks.

ivan-novakov commented 10 years ago

It was not a big deal. It would be more challenging to implement a restriction for the maximum number of concurent uploads :).