digest ok

This commit is contained in:
fyears 2024-01-21 14:19:27 +08:00
parent 0d9da32b00
commit 085d8448d2

View File

@ -45,6 +45,7 @@ if (VALID_REQURL) {
method: options.method, method: options.method,
body: options.data as string | ArrayBuffer, body: options.data as string | ArrayBuffer,
headers: transformedHeaders, headers: transformedHeaders,
throw: false,
}); });
let contentType: string | undefined = let contentType: string | undefined =
@ -237,29 +238,30 @@ export class WrappedWebdavClient {
init = async () => { init = async () => {
// init client if not inited // init client if not inited
if (this.client !== undefined) {
return;
}
const headers = { const headers = {
"Cache-Control": "no-cache", "Cache-Control": "no-cache",
}; };
if (this.client === undefined) { if (
if ( this.webdavConfig.username !== "" &&
this.webdavConfig.username !== "" && this.webdavConfig.password !== ""
this.webdavConfig.password !== "" ) {
) { this.client = createClient(this.webdavConfig.address, {
this.client = createClient(this.webdavConfig.address, { username: this.webdavConfig.username,
username: this.webdavConfig.username, password: this.webdavConfig.password,
password: this.webdavConfig.password, headers: headers,
headers: headers, authType:
authType: this.webdavConfig.authType === "digest"
this.webdavConfig.authType === "digest" ? AuthType.Digest
? AuthType.Digest : AuthType.Password,
: AuthType.Password, });
}); } else {
} else { log.info("no password");
log.info("no password"); this.client = createClient(this.webdavConfig.address, {
this.client = createClient(this.webdavConfig.address, { headers: headers,
headers: headers, });
});
}
} }
// check vault folder // check vault folder
@ -581,7 +583,7 @@ export const checkConnectivity = async (
} }
try { try {
await client.init(); await client.init();
const results = await getRemoteMeta(client, `/${client.remoteBaseDir}`); const results = await getRemoteMeta(client, `/${client.remoteBaseDir}/`);
if (results === undefined) { if (results === undefined) {
const err = "results is undefined"; const err = "results is undefined";
log.error(err); log.error(err);