weixiyen / jquery-filedrop

jQuery plugin - drag and drop desktop files and POST to a URL to handle files.
958 stars 285 forks source link

afterAll not called if last file not uploaded successfully #111

Open DanClarke33 opened 11 years ago

DanClarke33 commented 11 years ago

If the last file that is processed results in anything other than a successfull upload then afterAll is not called.

I observed this when returning false from some beforeEach calls, if the last file to be processed returns false then afterAll will not be called.

From examining the code the cause of this is because the call to afterAll is only fired after a completed file upload. So if you prevent any files from reaching that stage by returning false from beforeEach this issue will be experienced.

I resolved this for my usage very simply by making the following change:

Ln 306 At the end of the process function add the following lines:

if (filesDone == files_count - filesRejected) { afterAll(); }

This will fire the afterAll function after all files have been processed by the process function but wont fire the afterAll function if any files are still in the process of uploading as filesDone wont yet be incremented in that case.

Have submitted a change proposal with this fix and the fix for issue #110