fix(mount): mark test connection using stored password
This commit is contained in:
parent
96b3d8679b
commit
099f7c0628
|
|
@ -153,9 +153,17 @@ export const mountService = {
|
|||
}
|
||||
// 编辑时密码留空:复用已存密文测连,避免每次重填
|
||||
let password = input.password;
|
||||
let usedStored = false;
|
||||
if (!password && input.mountId && userId) {
|
||||
const existing = await mountDao.getByIdForUser(input.mountId, userId);
|
||||
if (existing?.secretEnc) password = decryptSecret(existing.secretEnc);
|
||||
if (existing?.secretEnc) {
|
||||
try {
|
||||
password = decryptSecret(existing.secretEnc);
|
||||
usedStored = true;
|
||||
} catch {
|
||||
// 密钥不一致等,退回空密码
|
||||
}
|
||||
}
|
||||
}
|
||||
try {
|
||||
const client = createWebdav({
|
||||
|
|
@ -166,19 +174,26 @@ export const mountService = {
|
|||
const root = normalizeWebdavPath(input.rootPath || "/");
|
||||
try {
|
||||
await listDirectory(client, root);
|
||||
return { ok: true, message: "连接成功" };
|
||||
return {
|
||||
ok: true,
|
||||
message: usedStored ? "连接成功(使用已保存的密码)" : "连接成功",
|
||||
};
|
||||
} catch (e) {
|
||||
// 根路径失败:再探 / 仅用于补充提示,不以 / 的成败作为结论
|
||||
// (部分 NAS 禁止列 /,或 / 与共享根权限不同)
|
||||
try {
|
||||
await listDirectory(client, "/");
|
||||
} catch {
|
||||
// 忽略
|
||||
// 忽略根探测
|
||||
}
|
||||
return { ok: false, message: describeWebdavError(e, root) };
|
||||
const base = describeWebdavError(e);
|
||||
return {
|
||||
ok: false,
|
||||
message: usedStored
|
||||
? `${base}(使用已保存的密码)`
|
||||
: base,
|
||||
};
|
||||
}
|
||||
} catch (e) {
|
||||
return { ok: false, message: describeWebdavError(e, input.rootPath || "/") };
|
||||
return { ok: false, message: describeWebdavError(e) };
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue