more verbose reason for conn fail
This commit is contained in:
parent
63a66d69f9
commit
4f3e8803da
@ -271,15 +271,22 @@ export class RemoteClient {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
checkConnectivity = async () => {
|
checkConnectivity = async (callbackFunc?: any) => {
|
||||||
if (this.serviceType === "s3") {
|
if (this.serviceType === "s3") {
|
||||||
return await s3.checkConnectivity(this.s3Client, this.s3Config);
|
return await s3.checkConnectivity(
|
||||||
|
this.s3Client,
|
||||||
|
this.s3Config,
|
||||||
|
callbackFunc
|
||||||
|
);
|
||||||
} else if (this.serviceType === "webdav") {
|
} else if (this.serviceType === "webdav") {
|
||||||
return await webdav.checkConnectivity(this.webdavClient);
|
return await webdav.checkConnectivity(this.webdavClient, callbackFunc);
|
||||||
} else if (this.serviceType === "dropbox") {
|
} else if (this.serviceType === "dropbox") {
|
||||||
return await dropbox.checkConnectivity(this.dropboxClient);
|
return await dropbox.checkConnectivity(this.dropboxClient, callbackFunc);
|
||||||
} else if (this.serviceType === "onedrive") {
|
} else if (this.serviceType === "onedrive") {
|
||||||
return await onedrive.checkConnectivity(this.onedriveClient);
|
return await onedrive.checkConnectivity(
|
||||||
|
this.onedriveClient,
|
||||||
|
callbackFunc
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
throw Error(`not supported service type ${this.serviceType}`);
|
throw Error(`not supported service type ${this.serviceType}`);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -636,7 +636,10 @@ export const deleteFromRemote = async (
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const checkConnectivity = async (client: WrappedDropboxClient) => {
|
export const checkConnectivity = async (
|
||||||
|
client: WrappedDropboxClient,
|
||||||
|
callbackFunc?: any
|
||||||
|
) => {
|
||||||
try {
|
try {
|
||||||
const results = await getRemoteMeta(client, "/");
|
const results = await getRemoteMeta(client, "/");
|
||||||
if (results === undefined) {
|
if (results === undefined) {
|
||||||
@ -644,8 +647,10 @@ export const checkConnectivity = async (client: WrappedDropboxClient) => {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error("dropbox connectivity error:");
|
log.debug(err);
|
||||||
console.error(err);
|
if (callbackFunc !== undefined) {
|
||||||
|
callbackFunc(err);
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@ -866,11 +866,18 @@ export const deleteFromRemote = async (
|
|||||||
await client.deleteJson(remoteFileName);
|
await client.deleteJson(remoteFileName);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const checkConnectivity = async (client: WrappedOnedriveClient) => {
|
export const checkConnectivity = async (
|
||||||
|
client: WrappedOnedriveClient,
|
||||||
|
callbackFunc?: any
|
||||||
|
) => {
|
||||||
try {
|
try {
|
||||||
const k = await getUserDisplayName(client);
|
const k = await getUserDisplayName(client);
|
||||||
return k !== "<unknown display name>";
|
return k !== "<unknown display name>";
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
log.debug(err);
|
||||||
|
if (callbackFunc !== undefined) {
|
||||||
|
callbackFunc(err);
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@ -498,7 +498,8 @@ export const deleteFromRemote = async (
|
|||||||
*/
|
*/
|
||||||
export const checkConnectivity = async (
|
export const checkConnectivity = async (
|
||||||
s3Client: S3Client,
|
s3Client: S3Client,
|
||||||
s3Config: S3Config
|
s3Config: S3Config,
|
||||||
|
callbackFunc?: any
|
||||||
) => {
|
) => {
|
||||||
try {
|
try {
|
||||||
const results = await s3Client.send(
|
const results = await s3Client.send(
|
||||||
@ -509,10 +510,19 @@ export const checkConnectivity = async (
|
|||||||
results.$metadata === undefined ||
|
results.$metadata === undefined ||
|
||||||
results.$metadata.httpStatusCode === undefined
|
results.$metadata.httpStatusCode === undefined
|
||||||
) {
|
) {
|
||||||
|
const err = "results or $metadata or httStatusCode is undefined";
|
||||||
|
log.debug(err);
|
||||||
|
if (callbackFunc !== undefined) {
|
||||||
|
callbackFunc(err);
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return results.$metadata.httpStatusCode === 200;
|
return results.$metadata.httpStatusCode === 200;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
log.debug(err);
|
||||||
|
if (callbackFunc !== undefined) {
|
||||||
|
callbackFunc(err);
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@ -523,15 +523,27 @@ export const deleteFromRemote = async (
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const checkConnectivity = async (client: WrappedWebdavClient) => {
|
export const checkConnectivity = async (
|
||||||
|
client: WrappedWebdavClient,
|
||||||
|
callbackFunc?: any
|
||||||
|
) => {
|
||||||
try {
|
try {
|
||||||
await client.init();
|
await client.init();
|
||||||
const results = await getRemoteMeta(client, "/");
|
const results = await getRemoteMeta(client, "/");
|
||||||
if (results === undefined) {
|
if (results === undefined) {
|
||||||
|
const err = "results is undefined";
|
||||||
|
log.debug(err);
|
||||||
|
if (callbackFunc !== undefined) {
|
||||||
|
callbackFunc(err);
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
log.debug(err);
|
||||||
|
if (callbackFunc !== undefined) {
|
||||||
|
callbackFunc(err);
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@ -826,11 +826,15 @@ export class RemotelySaveSettingTab extends PluginSettingTab {
|
|||||||
button.onClick(async () => {
|
button.onClick(async () => {
|
||||||
new Notice(t("settings_checkonnectivity_checking"));
|
new Notice(t("settings_checkonnectivity_checking"));
|
||||||
const client = new RemoteClient("s3", this.plugin.settings.s3);
|
const client = new RemoteClient("s3", this.plugin.settings.s3);
|
||||||
const res = await client.checkConnectivity();
|
const errors = { msg: "" };
|
||||||
|
const res = await client.checkConnectivity((err: any) => {
|
||||||
|
errors.msg = err;
|
||||||
|
});
|
||||||
if (res) {
|
if (res) {
|
||||||
new Notice(t("settings_s3_connect_succ"));
|
new Notice(t("settings_s3_connect_succ"));
|
||||||
} else {
|
} else {
|
||||||
new Notice(t("settings_s3_connect_fail"));
|
new Notice(t("settings_s3_connect_fail"));
|
||||||
|
new Notice(errors.msg);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -959,11 +963,15 @@ export class RemotelySaveSettingTab extends PluginSettingTab {
|
|||||||
() => self.plugin.saveSettings()
|
() => self.plugin.saveSettings()
|
||||||
);
|
);
|
||||||
|
|
||||||
const res = await client.checkConnectivity();
|
const errors = { msg: "" };
|
||||||
|
const res = await client.checkConnectivity((err: any) => {
|
||||||
|
errors.msg = `${err}`;
|
||||||
|
});
|
||||||
if (res) {
|
if (res) {
|
||||||
new Notice(t("settings_dropbox_connect_succ"));
|
new Notice(t("settings_dropbox_connect_succ"));
|
||||||
} else {
|
} else {
|
||||||
new Notice(t("settings_dropbox_connect_fail"));
|
new Notice(t("settings_dropbox_connect_fail"));
|
||||||
|
new Notice(errors.msg);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -1074,11 +1082,15 @@ export class RemotelySaveSettingTab extends PluginSettingTab {
|
|||||||
() => self.plugin.saveSettings()
|
() => self.plugin.saveSettings()
|
||||||
);
|
);
|
||||||
|
|
||||||
const res = await client.checkConnectivity();
|
const errors = { msg: "" };
|
||||||
|
const res = await client.checkConnectivity((err: any) => {
|
||||||
|
errors.msg = `${err}`;
|
||||||
|
});
|
||||||
if (res) {
|
if (res) {
|
||||||
new Notice(t("settings_onedrive_connect_succ"));
|
new Notice(t("settings_onedrive_connect_succ"));
|
||||||
} else {
|
} else {
|
||||||
new Notice(t("settings_onedrive_connect_fail"));
|
new Notice(t("settings_onedrive_connect_fail"));
|
||||||
|
new Notice(errors.msg);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -1230,7 +1242,10 @@ export class RemotelySaveSettingTab extends PluginSettingTab {
|
|||||||
this.app.vault.getName(),
|
this.app.vault.getName(),
|
||||||
() => self.plugin.saveSettings()
|
() => self.plugin.saveSettings()
|
||||||
);
|
);
|
||||||
const res = await client.checkConnectivity();
|
const errors = { msg: "" };
|
||||||
|
const res = await client.checkConnectivity((err: any) => {
|
||||||
|
errors.msg = `${err}`;
|
||||||
|
});
|
||||||
if (res) {
|
if (res) {
|
||||||
new Notice(t("settings_webdav_connect_succ"));
|
new Notice(t("settings_webdav_connect_succ"));
|
||||||
} else {
|
} else {
|
||||||
@ -1244,6 +1259,7 @@ export class RemotelySaveSettingTab extends PluginSettingTab {
|
|||||||
corsErrMsg: corsErrMsg,
|
corsErrMsg: corsErrMsg,
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
new Notice(errors.msg);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user