1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-06-12 22:57:38 +02:00

All: Dropbox: Handle various error conditions

This commit is contained in:
Laurent Cozic
2018-03-27 00:05:39 +01:00
parent 3c2281dbf9
commit 6e994fd8b9
7 changed files with 60 additions and 33 deletions

View File

@ -40,10 +40,6 @@ class SyncTargetDropbox extends BaseSyncTarget {
return fileApi.driver().api();
}
syncTargetId() {
return SyncTargetDropbox.id();
}
async initFileApi() {
const params = parameters().dropbox;
@ -52,15 +48,17 @@ class SyncTargetDropbox extends BaseSyncTarget {
secret: params.secret,
});
const authJson = Setting.value('sync.' + SyncTargetDropbox.id() + '.auth');
if (authJson) {
const auth = JSON.parse(authJson);
api.setAuthToken(auth.access_token);
}
api.on('authRefreshed', (auth) => {
this.logger().info('Saving updated OneDrive auth.');
Setting.setValue('sync.' + SyncTargetDropbox.id() + '.auth', auth ? auth : null);
});
const authToken = Setting.value('sync.' + SyncTargetDropbox.id() + '.auth');
api.setAuthToken(authToken);
const appDir = '';
const fileApi = new FileApi(appDir, new FileApiDriverDropbox(api));
fileApi.setSyncTargetId(this.syncTargetId());
fileApi.setSyncTargetId(SyncTargetDropbox.id());
fileApi.setLogger(this.logger());
return fileApi;
}