fix symlink overwritten, remove unused scripts
This commit is contained in:
parent
fa1c8e9354
commit
e63be86ba5
@ -7,7 +7,7 @@
|
||||
// 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)
|
||||
import { mkdirSync, readFileSync, writeFileSync, renameSync } from "node:fs";
|
||||
import { mkdirSync, readFileSync, realpathSync, writeFileSync, renameSync } from "node:fs";
|
||||
import { homedir } from "node:os";
|
||||
import { dirname, join } from "node:path";
|
||||
import readline from "node:readline";
|
||||
@ -161,6 +161,12 @@ function modelEntry(catalogModel, vision) {
|
||||
}
|
||||
|
||||
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`;
|
||||
writeFileSync(tmp, contents);
|
||||
renameSync(tmp, path);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user