fix(mount): rootPath is source of truth for WebDAV test
Do not fail when listing / fails; many NAS forbid listing root.
This commit is contained in:
parent
a7a50f8d0a
commit
7db51693ad
|
|
@ -163,19 +163,20 @@ export const mountService = {
|
||||||
username: input.username,
|
username: input.username,
|
||||||
password,
|
password,
|
||||||
});
|
});
|
||||||
// 1) 先探 WebDAV 根:区分「认证/不是 WebDAV」与「根路径写错」
|
|
||||||
try {
|
|
||||||
await listDirectory(client, "/");
|
|
||||||
} catch (e) {
|
|
||||||
const msg = describeWebdavError(e);
|
|
||||||
if (msg.includes("认证失败") || msg.includes("不是 WebDAV") || msg.includes("连接")) {
|
|
||||||
return { ok: false, message: `${msg}(探测 WebDAV 根路径 / 时失败)` };
|
|
||||||
}
|
|
||||||
// 根 400 等:仍继续试 rootPath,部分服务根不可列
|
|
||||||
}
|
|
||||||
const root = normalizeWebdavPath(input.rootPath || "/");
|
const root = normalizeWebdavPath(input.rootPath || "/");
|
||||||
|
try {
|
||||||
await listDirectory(client, root);
|
await listDirectory(client, root);
|
||||||
return { ok: true, message: "连接成功" };
|
return { ok: true, message: "连接成功" };
|
||||||
|
} catch (e) {
|
||||||
|
// 根路径失败:再探 / 仅用于补充提示,不以 / 的成败作为结论
|
||||||
|
// (部分 NAS 禁止列 /,或 / 与共享根权限不同)
|
||||||
|
try {
|
||||||
|
await listDirectory(client, "/");
|
||||||
|
} catch {
|
||||||
|
// 忽略
|
||||||
|
}
|
||||||
|
return { ok: false, message: describeWebdavError(e, root) };
|
||||||
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return { ok: false, message: describeWebdavError(e, input.rootPath || "/") };
|
return { ok: false, message: describeWebdavError(e, input.rootPath || "/") };
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue