Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix:when upload large file,we cant stop #3373

Merged
merged 2 commits into from
Mar 8, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions notebook/static/tree/js/notebooklist.js
Original file line number Diff line number Diff line change
Expand Up @@ -1220,12 +1220,14 @@ define([
NotebookList.prototype.add_large_file_upload_button = function (file) {
var that = this;
var item = that.new_item(0, true);
var stop_signal = false;
item.addClass('new-file');
that.add_name_input(file.name, item, 'file');
var cancel_button = $('<button/>').text("Cancel")
.addClass("btn btn-default btn-xs")
.click(function (e) {
item.remove();
stop_signal = true;
return false;
});

Expand All @@ -1250,7 +1252,7 @@ define([
if ($(v).data('name') === filename) { exists = true; return false; }
});
return exists
}
};
var exists = check_exist();

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

var large_reader_onload = function (event) {
if (stop_signal === true) {
return;
}
if (event.target.error == null) {
offset += chunk_size;
if (offset >= f.size) {
Expand Down Expand Up @@ -1305,7 +1310,7 @@ define([
body : "Failed to read file '" + name + "'",
buttons : {'OK' : { 'class' : 'btn-primary' }}
});
}
};

chunk_reader = function (_offset, _f) {
var reader = new FileReader();
Expand Down Expand Up @@ -1363,7 +1368,7 @@ define([
}
};
that.contents.save(path, model).then(on_success, on_error);
}
};

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