1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-06-15 23:00:36 +02:00

Allow cancelling sync and fixed resource issue

This commit is contained in:
Laurent Cozic
2017-07-09 16:47:05 +01:00
parent de16573742
commit 297edfa682
11 changed files with 210 additions and 33 deletions

View File

@ -1,6 +1,7 @@
import { shim } from 'lib/shim.js';
import { stringify } from 'query-string';
import { time } from 'lib/time-utils.js';
import { Logger } from 'lib/logger.js'
class OneDriveApi {
@ -16,6 +17,15 @@ class OneDriveApi {
this.listeners_ = {
'authRefreshed': [],
};
this.logger_ = new Logger();
}
setLogger(l) {
this.logger_ = l;
}
logger() {
return this.logger_;
}
isPublic() {
@ -161,17 +171,19 @@ class OneDriveApi {
let error = this.oneDriveErrorResponseToError(errorResponse);
if (error.code == 'InvalidAuthenticationToken' || error.code == 'unauthenticated') {
this.logger().info('Token expired: refreshing...');
await this.refreshAccessToken();
continue;
} else if (error && ((error.error && error.error.code == 'generalException') || (error.code == 'generalException'))) {
// Rare error (one Google hit) - I guess the request can be repeated
// { error:
// { code: 'generalException',
// message: 'An error occurred in the data store.',
// innerError:
// { 'request-id': 'b4310552-c18a-45b1-bde1-68e2c2345eef',
// date: '2017-06-29T00:15:50' } } }
this.logger().info('Got error below - retrying...');
this.logger().info(error);
await time.msleep(1000 * i);
continue;
} else if (error.code == 'EAGAIN') {
@ -181,6 +193,8 @@ class OneDriveApi {
// type: 'system',
// errno: 'EAGAIN',
// code: 'EAGAIN' }
this.logger().info('Got error below - retrying...');
this.logger().info(error);
await time.msleep(1000 * i);
continue;
} else {