{"draft":null,"from":2,"to":318,"files":[{"path":"client/src/lock.ts","added":8,"removed":7,"diff":"--- a/client/src/lock.ts\n+++ b/client/src/lock.ts\n@@ -8,17 +8,18 @@\n //\n // The lock is never there without its contents: they're written to a file of\n // the taker's own and linked into place, which fails if a lock exists\n-// (AVCS - Git Lessons). Its holder renews it every RENEW_MS, so a lock not\n+// already. Its holder renews it every RENEW_MS, so a lock not\n // renewed for LOCK_STALE_MS was left behind, whatever process now has its\n // id; a long record or sync is never taken over while it writes. Taking one\n // over goes through a rename aside, which only one process can win.\n \n import { closeSync, linkSync, openSync, readFileSync, renameSync, rmSync, statSync, writeSync } from \"node:fs\";\n-import { join } from \"node:path\";\n+import { basename, join } from \"node:path\";\n import { UsageError } from \"./args.ts\";\n-import { AVCS_DIR } from \"./config.ts\";\n import { LOCK_FILE, LOCK_STALE_MS, type LockInfo } from \"./core.ts\";\n+import { fromEnv } from \"./env-names.ts\";\n import { writeFileAtomic } from \"./folder.ts\";\n+import { stateDir } from \"./state-dir.ts\";\n \n /** How long a command waits for the lock before it says who holds it. */\n const WAIT_MS = 3000;\n@@ -28,7 +29,7 @@\n /** Locks this process holds, by folder, and how deep: a locked call inside another one doesn't wait for itself. */\n const held = new Map<string, { depth: number; renew: ReturnType<typeof setInterval> }>();\n \n-const lockPath = (root: string): string => join(root, AVCS_DIR, LOCK_FILE);\n+const lockPath = (root: string): string => join(stateDir(root), LOCK_FILE);\n \n function readInfo(path: string): LockInfo | undefined {\n \ttry {\n@@ -142,8 +143,8 @@\n \tconst mine = held.get(root);\n \tif (mine) mine.depth++;\n \telse {\n-\t\t// AVCS_LOCK_WAIT_MS shortens the wait in tests.\n-\t\tconst until = Date.now() + (Number(process.env.AVCS_LOCK_WAIT_MS) || WAIT_MS);\n+\t\t// ABSO_LOCK_WAIT_MS shortens the wait in tests.\n+\t\tconst until = Date.now() + (Number(fromEnv(process.env, \"LOCK_WAIT_MS\")) || WAIT_MS);\n \t\tfor (;;) {\n \t\t\tconst got = take(root, what);\n \t\t\tif (got === \"no folder\") return fn(); // no .avcs/ yet (init): nothing to protect\n@@ -152,7 +153,7 @@\n \t\t\t\tconst info = readInfo(lockPath(root));\n \t\t\t\tconst since = info ? new Date(info.time).toISOString().slice(11, 19) : \"?\";\n \t\t\t\tthrow new UsageError(\n-\t\t\t\t\t`another abso command (${info?.what ?? \"one\"}, process ${info?.pid ?? \"?\"}, since ${since} UTC) is changing this folder's records; run this again when it has finished. If none is running, delete .avcs/lock.`,\n+\t\t\t\t\t`another abso command (${info?.what ?? \"one\"}, process ${info?.pid ?? \"?\"}, since ${since} UTC) is changing this folder's records; run this again when it has finished. If none is running, delete ${basename(stateDir(root))}/lock.`,\n \t\t\t\t);\n \t\t\t}\n \t\t\tawait new Promise((ok) => setTimeout(ok, 50));"}],"unmatched":[]}