style(copy): punctuation rules and site-wide fix with a CI check (QA U11)
- glossary: 10 punctuation rules (full-width in Chinese, CJK/Latin spacing, full-width parens around Chinese, single ellipsis, 「」 quotes, period rules) - scripts/check-copy-punctuation.mjs: checks string literals, templates and JSX text (not comments, types, keys, match/compare strings); --fix, --strict, --by-file; wired into deno task ci as check:copy in warn mode - --fix applied to web, server and contracts; files other lanes were editing (subscriptions, sites, browser, agent, auth/account, inventory) left for them - tests updated for the changed messages Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
9b017906cf
commit
52402864d6
143 files changed
+985
-606
No files matched your search
@@ -16,7 +16,7 @@ const parentRel = (rel: string) => (rel.includes("/") ? dirname(rel) : "");
|
||||
|
||||
function assertCleanName(name: string) {
|
||||
if (sanitizeSegment(name) !== name)
|
||||
throw new FilesError("bad_request", `文件名含非法字符或首尾有空白/点,可改为:${sanitizeSegment(name)}`);
|
||||
throw new FilesError("bad_request", `文件名含非法字符或首尾有空白/点,可改为:${sanitizeSegment(name)}`);
|
||||
}
|
||||
|
||||
export async function mkdirIn(
|
||||
@@ -26,15 +26,15 @@ export async function mkdirIn(
|
||||
): Promise<FilesMkdirResult> {
|
||||
const r = await resolveIn(d, body.root, body.path);
|
||||
if (!(await isWritableTarget(r.def, r.rootReal))) throw new FilesError("not_writable", `根 ${r.def.name} 不可写`);
|
||||
if (!r.lst?.isDirectory() || r.isSymlink) throw new FilesError("bad_request", `不是目录: ${r.rel || "/"}`);
|
||||
if (!r.lst?.isDirectory() || r.isSymlink) throw new FilesError("bad_request", `不是目录:${r.rel || "/"}`);
|
||||
assertCleanName(body.name);
|
||||
await recheck(r.abs, r.rootReal);
|
||||
const abs = join(r.abs, body.name);
|
||||
try {
|
||||
await mkdir(abs);
|
||||
} catch (e) {
|
||||
if (errnoOf(e) === "EEXIST") throw new FilesError("exists", `已存在: ${body.name}`);
|
||||
throw new FilesError("bad_request", `创建目录失败: ${errMessage(e)}`);
|
||||
if (errnoOf(e) === "EEXIST") throw new FilesError("exists", `已存在:${body.name}`);
|
||||
throw new FilesError("bad_request", `创建目录失败:${errMessage(e)}`);
|
||||
}
|
||||
const rel = relOf(r.rootReal, abs);
|
||||
await audit(d, principal, "mkdir", { root: body.root, path: rel });
|
||||
@@ -57,7 +57,7 @@ export async function renameEntry(
|
||||
): Promise<FilesRenameResult> {
|
||||
const r = await resolveIn(d, body.root, body.path);
|
||||
if (r.rel === "") throw new FilesError("bad_request", "根目录不能重命名");
|
||||
if (!r.def.modifiable) throw new FilesError("not_writable", `根 ${r.def.name} 只读,不能重命名`);
|
||||
if (!r.def.modifiable) throw new FilesError("not_writable", `根 ${r.def.name} 只读,不能重命名`);
|
||||
assertCleanName(body.newName);
|
||||
const oldName = basename(r.abs);
|
||||
if (body.newName === oldName) throw new FilesError("bad_request", "新名称与原名称相同");
|
||||
@@ -68,7 +68,7 @@ export async function renameEntry(
|
||||
if (hits.length > 0)
|
||||
throw new FilesError(
|
||||
"download_active",
|
||||
`该路径属于下载任务 ${hits.map((h) => h.taskId).join(", ")},重命名会让下载器找不到文件。先整理入库再改`,
|
||||
`该路径属于下载任务 ${hits.map((h) => h.taskId).join(", ")},重命名会让下载器找不到文件。先整理入库再改`,
|
||||
);
|
||||
|
||||
const dirAbs = dirname(r.abs);
|
||||
@@ -91,7 +91,7 @@ export async function renameEntry(
|
||||
const st = await lstat(p.toAbs).catch((e) => (errnoOf(e) === "ENOENT" ? null : e));
|
||||
if (st) taken.push(p.to);
|
||||
}
|
||||
if (taken.length > 0) throw new FilesError("exists", `目标已存在,不覆盖: ${taken.join(", ")}`);
|
||||
if (taken.length > 0) throw new FilesError("exists", `目标已存在,不覆盖:${taken.join(", ")}`);
|
||||
|
||||
const lib = r.def.libraryRootId;
|
||||
let locCount = 0;
|
||||
@@ -123,11 +123,11 @@ export async function renameEntry(
|
||||
await recheck(p.fromAbs, r.rootReal);
|
||||
const before = await lstat(p.fromAbs);
|
||||
const res = await moveSafe(p.fromAbs, p.toAbs);
|
||||
if (res.status === "exists") throw new FilesError("exists", `目标已存在,不覆盖: ${p.to}`);
|
||||
if (res.status === "exists") throw new FilesError("exists", `目标已存在,不覆盖:${p.to}`);
|
||||
if (res.status !== "moved") throw new FilesError("bad_request", `重命名失败(${res.status}): ${p.from}`);
|
||||
const after = await lstat(p.toAbs);
|
||||
if (after.ino !== before.ino || after.dev !== before.dev)
|
||||
throw new FilesError("bad_request", `重命名后 inode 不一致,已中止: ${p.to}`);
|
||||
throw new FilesError("bad_request", `重命名后 inode 不一致,已中止:${p.to}`);
|
||||
done.push(p);
|
||||
} catch (e) {
|
||||
await rollback();
|
||||
|
||||
Reference in new issue
Block a user