1
0
mirror of https://github.com/ascribe/onion.git synced 2025-01-03 10:25:08 +01: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 the all function for iterables and essentially replace all original files
// with their txt representative // with their txt representative
Q.all(convertedFilePromises) Q.all(convertedFilePromises)
.progress(({index, value: {progress, handleError}}) => { .progress(({index, value: {progress, reject}}) => {
// hashing progress has been aborted from outside // hashing progress has been aborted from outside
// To get out of the executing, we need to call reject from the // 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 // In the promises catch method, we're then checking if the interruption
// was due to that error or another generic one. // was due to that error or another generic one.
if(this.state.hashingProgress === -1) { if(this.state.hashingProgress === -1) {
handleError(new Error(getLangText('Hashing canceled'))); reject(new Error(getLangText('Hashing canceled')));
} }
// update file's progress // update file's progress

View File

@ -69,11 +69,13 @@ export function computeHashOfFile(file) {
end = ((start + chunkSize) >= file.size) ? file.size : start + chunkSize; end = ((start + chunkSize) >= file.size) ? file.size : start + chunkSize;
// send progress // 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({ notify({
progress: start / file.size, progress: start / file.size,
handleError(err) { reject
reject(err);
}
}); });
fileReader.readAsArrayBuffer(blobSlice.call(file, start, end)); fileReader.readAsArrayBuffer(blobSlice.call(file, start, end));