Skip to content

Commit c1c7d3d

Browse files
authored
Merge pull request #3373 from forbxy/fix-file-upload
fix:when upload large file,we cant stop
2 parents 290e574 + 191be80 commit c1c7d3d

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

notebook/static/tree/js/notebooklist.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1220,12 +1220,14 @@ define([
12201220
NotebookList.prototype.add_large_file_upload_button = function (file) {
12211221
var that = this;
12221222
var item = that.new_item(0, true);
1223+
var stop_signal = false;
12231224
item.addClass('new-file');
12241225
that.add_name_input(file.name, item, 'file');
12251226
var cancel_button = $('<button/>').text("Cancel")
12261227
.addClass("btn btn-default btn-xs")
12271228
.click(function (e) {
12281229
item.remove();
1230+
stop_signal = true;
12291231
return false;
12301232
});
12311233

@@ -1250,7 +1252,7 @@ define([
12501252
if ($(v).data('name') === filename) { exists = true; return false; }
12511253
});
12521254
return exists
1253-
}
1255+
};
12541256
var exists = check_exist();
12551257

12561258
var add_uploading_button = function (f, item) {
@@ -1276,6 +1278,9 @@ define([
12761278
var upload_file = null;
12771279

12781280
var large_reader_onload = function (event) {
1281+
if (stop_signal === true) {
1282+
return;
1283+
}
12791284
if (event.target.error == null) {
12801285
offset += chunk_size;
12811286
if (offset >= f.size) {
@@ -1305,7 +1310,7 @@ define([
13051310
body : "Failed to read file '" + name + "'",
13061311
buttons : {'OK' : { 'class' : 'btn-primary' }}
13071312
});
1308-
}
1313+
};
13091314

13101315
chunk_reader = function (_offset, _f) {
13111316
var reader = new FileReader();
@@ -1363,7 +1368,7 @@ define([
13631368
}
13641369
};
13651370
that.contents.save(path, model).then(on_success, on_error);
1366-
}
1371+
};
13671372

13681373
// now let's start the read with the first block
13691374
chunk_reader(offset, f);

0 commit comments

Comments
 (0)