upload: Don't add remaining files if adding a file fails.

If a file cannot be added for upload because of restrictions in frontend
we call cancelAll immediately in 'info-visible' callback. This would
prevent files that are already added to be cancelled but does not cancel
files that are yet to be added. So we use break to prevent any more files
from being added.
This commit is contained in:
Vishnu KS
2020-04-16 20:41:06 +05:30
committed by Tim Abbott
parent 2f2c384c88
commit c06d29d0aa
2 changed files with 21 additions and 1 deletions

View File

@@ -146,7 +146,7 @@ run_test('show_error_message', () => {
run_test('upload_files', () => {
let uppy_cancel_all_called = false;
const files = [
let files = [
{
name: "budapest.png",
type: "image/png",
@@ -212,6 +212,25 @@ run_test('upload_files', () => {
assert(compose_ui_autosize_textarea_called);
assert(uppy_add_file_called);
files = [
{
name: "budapest.png",
type: "image/png",
},
{
name: "prague.png",
type: "image/png",
},
];
let add_file_counter = 0;
uppy.addFile = (file) => {
assert.equal(file.name, "budapest.png");
add_file_counter += 1;
throw Error();
};
upload.upload_files(uppy, config, files);
assert.equal(add_file_counter, 1);
global.patch_builtin("setTimeout", (func) => {
func();
});