1
0
mirror of https://github.com/ascribe/onion.git synced 2024-06-30 13:41:57 +02:00

simplified error handling in progress routine

This commit is contained in:
Tim Daubenschütz 2015-07-24 16:29:57 +02:00
parent a7a36589a7
commit e53a45822b
2 changed files with 7 additions and 5 deletions

View File

@ -526,7 +526,7 @@ var ReactS3FineUploader = React.createClass({
// with the all function for iterables and essentially replace all original files
// with their txt representative
Q.all(convertedFilePromises)
.progress(({index, value: {progress, handleError}}) => {
.progress(({index, value: {progress, reject}}) => {
// hashing progress has been aborted from outside
// To get out of the executing, we need to call reject from the
@ -537,7 +537,7 @@ var ReactS3FineUploader = React.createClass({
// In the promises catch method, we're then checking if the interruption
// was due to that error or another generic one.
if(this.state.hashingProgress === -1) {
handleError(new Error(getLangText('Hashing canceled')));
reject(new Error(getLangText('Hashing canceled')));
}
// update file's progress

View File

@ -69,11 +69,13 @@ export function computeHashOfFile(file) {
end = ((start + chunkSize) >= file.size) ? file.size : start + chunkSize;
// send progress
// Due to the fact that progressHandler and notify are going to be removed in v2
// of Q, the functionality of throwing errors in the progressHandler will not be implemented
// anymore. To still be able to throw an error however, we can just expose the promise's reject
// method to the .progress function to stop the execution immediately.
notify({
progress: start / file.size,
handleError(err) {
reject(err);
}
reject
});
fileReader.readAsArrayBuffer(blobSlice.call(file, start, end));