fix symlink overwritten, remove unused scripts

This commit is contained in:
nhat.nguyenhong 2026-10-08 13:04:19 +07:00
parent fa1c8e9354
commit e63be86ba5
2 changed files with 7 additions and 1211 deletions

View File

@ -7,7 +7,7 @@
// the result into the global opencode config. Deselecting a model removes it from the config. // the result into the global opencode config. Deselecting a model removes it from the config.
// //
// Run: node scripts/sync-models.mjs (build first: npm run build) // Run: node scripts/sync-models.mjs (build first: npm run build)
import { mkdirSync, readFileSync, writeFileSync, renameSync } from "node:fs"; import { mkdirSync, readFileSync, realpathSync, writeFileSync, renameSync } from "node:fs";
import { homedir } from "node:os"; import { homedir } from "node:os";
import { dirname, join } from "node:path"; import { dirname, join } from "node:path";
import readline from "node:readline"; import readline from "node:readline";
@ -161,6 +161,12 @@ function modelEntry(catalogModel, vision) {
} }
function writeAtomic(path, contents) { function writeAtomic(path, contents) {
// Write next to the real file: renaming over a symlink would replace the link itself.
try {
path = realpathSync(path);
} catch (error) {
if (error.code !== "ENOENT") throw error;
}
const tmp = `${path}.${process.pid}.tmp`; const tmp = `${path}.${process.pid}.tmp`;
writeFileSync(tmp, contents); writeFileSync(tmp, contents);
renameSync(tmp, path); renameSync(tmp, path);

1210
server.py

File diff suppressed because it is too large Load Diff