惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

The GitHub Blog
The GitHub Blog
Martin Fowler
Martin Fowler
Vercel News
Vercel News
U
Unit 42
Engineering at Meta
Engineering at Meta
aimingoo的专栏
aimingoo的专栏
MyScale Blog
MyScale Blog
Y
Y Combinator Blog
阮一峰的网络日志
阮一峰的网络日志
爱范儿
爱范儿
Apple Machine Learning Research
Apple Machine Learning Research
博客园_首页
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
B
Blog RSS Feed
N
Netflix TechBlog - Medium
GbyAI
GbyAI
F
Fortinet All Blogs
MongoDB | Blog
MongoDB | Blog
大猫的无限游戏
大猫的无限游戏
C
Check Point Blog
M
MIT News - Artificial intelligence
D
Docker
IT之家
IT之家
Stack Overflow Blog
Stack Overflow Blog

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
refactor: use fs-safe for staged package swaps · openclaw...
steipete · 2026-05-07 · via Recent Commits to openclaw:main

@@ -46,6 +46,10 @@ function normalizeComparablePath(filePath: string): string {

4646

return path.join(comparableParent, basename);

4747

}

484849+

function createFsError(code: string, message = code): NodeJS.ErrnoException {

50+

return Object.assign(new Error(message), { code });

51+

}

52+4953

async function rebindInstallBasePath(params: {

5054

installBaseDir: string;

5155

preservedDir: string;

@@ -207,6 +211,49 @@ describe("installPackageDir", () => {

207211

await expect(fs.readdir(backupRoot)).resolves.toHaveLength(0);

208212

});

209213214+

it("publishes the staged install through the copy fallback when rename crosses devices", async () => {

215+

await fixtureRootTracker.setup();

216+

const fixtureRoot = await fixtureRootTracker.make("case");

217+

const sourceDir = path.join(fixtureRoot, "source");

218+

const installBaseDir = path.join(fixtureRoot, "plugins");

219+

const targetDir = path.join(installBaseDir, "demo");

220+

await fs.mkdir(sourceDir, { recursive: true });

221+

await fs.writeFile(path.join(sourceDir, "marker.txt"), "new");

222+223+

const realRename = fs.rename.bind(fs);

224+

let exdevMoves = 0;

225+

vi.spyOn(fs, "rename").mockImplementation(async (...args: Parameters<typeof fs.rename>) => {

226+

const [from, to] = args;

227+

const fromPath = String(from);

228+

if (

229+

exdevMoves === 0 &&

230+

path.basename(fromPath).startsWith(".openclaw-install-stage-") &&

231+

normalizeComparablePath(String(to)) === normalizeComparablePath(targetDir)

232+

) {

233+

exdevMoves += 1;

234+

throw createFsError("EXDEV", "cross-device link not permitted");

235+

}

236+

return await realRename(...args);

237+

});

238+239+

const result = await installPackageDir({

240+

sourceDir,

241+

targetDir,

242+

mode: "install",

243+

timeoutMs: 1_000,

244+

copyErrorPrefix: "failed to copy plugin",

245+

hasDeps: false,

246+

depsLogMessage: "Installing deps…",

247+

});

248+249+

expect(result).toEqual({ ok: true });

250+

expect(exdevMoves).toBe(1);

251+

await expect(fs.readFile(path.join(targetDir, "marker.txt"), "utf8")).resolves.toBe("new");

252+

await expect(

253+

listMatchingDirs(installBaseDir, ".openclaw-install-stage-"),

254+

).resolves.toHaveLength(0);

255+

});

256+210257

it("aborts without outside writes when the install base is rebound before publish", async () => {

211258

await fixtureRootTracker.setup();

212259

const fixtureRoot = await fixtureRootTracker.make("case");

@@ -255,25 +302,36 @@ describe("installPackageDir", () => {

255302

await createReboundInstallFixture({ fixtureRoot, withExistingInstall: true });

256303257304

const warnings: string[] = [];

258-

const result = await withInstallBaseReboundOnRealpathCall({

259-

installBaseDir,

260-

preservedDir: preservedInstallRoot,

261-

outsideTarget: outsideInstallRoot,

262-

rebindAtCall: 8,

263-

run: async () =>

264-

await installPackageDir({

265-

sourceDir,

266-

targetDir,

267-

mode: "update",

268-

timeoutMs: 1_000,

269-

copyErrorPrefix: "failed to copy plugin",

270-

hasDeps: false,

271-

depsLogMessage: "Installing deps…",

272-

logger: { warn: (message) => warnings.push(message) },

273-

}),

305+

const installBasePath = normalizeComparablePath(installBaseDir);

306+

const realStat = fs.stat.bind(fs);

307+

let installBaseStatCalls = 0;

308+

vi.spyOn(fs, "stat").mockImplementation(async (...args: Parameters<typeof fs.stat>) => {

309+

if (normalizeComparablePath(String(args[0])) === installBasePath) {

310+

installBaseStatCalls += 1;

311+

if (installBaseStatCalls === 3) {

312+

await rebindInstallBasePath({

313+

installBaseDir,

314+

preservedDir: preservedInstallRoot,

315+

outsideTarget: outsideInstallRoot,

316+

});

317+

}

318+

}

319+

return await realStat(...args);

320+

});

321+322+

const result = await installPackageDir({

323+

sourceDir,

324+

targetDir,

325+

mode: "update",

326+

timeoutMs: 1_000,

327+

copyErrorPrefix: "failed to copy plugin",

328+

hasDeps: false,

329+

depsLogMessage: "Installing deps…",

330+

logger: { warn: (message) => warnings.push(message) },

274331

});

275332276333

expect(result).toEqual({ ok: true });

334+

expect(installBaseStatCalls).toBe(3);

277335

expect(warnings).toContain(

278336

"Install base directory changed before backup cleanup; leaving backup in place.",

279337

);