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

Desktop: Improved Joplin Server error handling

This commit is contained in:
Laurent Cozic
2021-06-08 01:34:33 +02:00
parent de7579a14e
commit 95d7ccccea
4 changed files with 34 additions and 14 deletions

View File

@@ -31,8 +31,8 @@ export async function newFileApi(id: number, options: FileApiOptions) {
return fileApi;
}
export async function initFileApi(logger: Logger, options: FileApiOptions) {
const fileApi = await newFileApi(SyncTargetJoplinServer.id(), options);
export async function initFileApi(syncTargetId: number, logger: Logger, options: FileApiOptions) {
const fileApi = await newFileApi(syncTargetId, options);
fileApi.setLogger(logger);
return fileApi;
}
@@ -63,14 +63,16 @@ export default class SyncTargetJoplinServer extends BaseSyncTarget {
return super.fileApi();
}
public static async checkConfig(options: FileApiOptions) {
public static async checkConfig(options: FileApiOptions, syncTargetId: number = null) {
const output = {
ok: false,
errorMessage: '',
};
syncTargetId = syncTargetId === null ? SyncTargetJoplinServer.id() : syncTargetId;
try {
const fileApi = await newFileApi(SyncTargetJoplinServer.id(), options);
const fileApi = await newFileApi(syncTargetId, options);
fileApi.requestRepeatCount_ = 0;
await fileApi.put('testing.txt', 'testing');
@@ -87,7 +89,7 @@ export default class SyncTargetJoplinServer extends BaseSyncTarget {
}
protected async initFileApi() {
return initFileApi(this.logger(), {
return initFileApi(SyncTargetJoplinServer.id(), this.logger(), {
path: () => Setting.value('sync.9.path'),
userContentPath: () => Setting.value('sync.9.userContentPath'),
username: () => Setting.value('sync.9.username'),