mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 08:30:42 +00:00
fix: materialize stale runtime mirror symlinks
This commit is contained in:
@@ -240,6 +240,30 @@ describe("installBundledRuntimeDeps", () => {
|
||||
expect(fs.readFileSync(chunkPath, "utf8")).toContain("same-file");
|
||||
});
|
||||
|
||||
it("replaces stale mirror symlinks when materializing chunks", () => {
|
||||
const tempDir = makeTempDir();
|
||||
const sourcePath = path.join(tempDir, "dist", "accounts.js");
|
||||
const targetPath = path.join(tempDir, "stage", "dist", "accounts.js");
|
||||
fs.mkdirSync(path.dirname(sourcePath), { recursive: true });
|
||||
fs.mkdirSync(path.dirname(targetPath), { recursive: true });
|
||||
fs.writeFileSync(
|
||||
sourcePath,
|
||||
[
|
||||
`//#region extensions/slack/src/accounts.ts`,
|
||||
`export const marker = "source";`,
|
||||
`//#endregion`,
|
||||
"",
|
||||
].join("\n"),
|
||||
"utf8",
|
||||
);
|
||||
fs.symlinkSync(sourcePath, targetPath, "file");
|
||||
|
||||
materializeBundledRuntimeMirrorDistFile(sourcePath, targetPath);
|
||||
|
||||
expect(fs.lstatSync(targetPath).isSymbolicLink()).toBe(false);
|
||||
expect(fs.readFileSync(targetPath, "utf8")).toContain("source");
|
||||
});
|
||||
|
||||
it("uses a real write probe for runtime dependency roots", () => {
|
||||
const accessSpy = vi.spyOn(fs, "accessSync").mockImplementation(() => undefined);
|
||||
const mkdirSpy = vi.spyOn(fs, "mkdtempSync").mockImplementation(() => {
|
||||
|
||||
@@ -91,7 +91,10 @@ export function materializeBundledRuntimeMirrorDistFile(
|
||||
return;
|
||||
}
|
||||
try {
|
||||
if (fs.realpathSync(sourcePath) === fs.realpathSync(targetPath)) {
|
||||
if (
|
||||
fs.realpathSync(sourcePath) === fs.realpathSync(targetPath) &&
|
||||
!fs.lstatSync(targetPath).isSymbolicLink()
|
||||
) {
|
||||
return;
|
||||
}
|
||||
} catch {
|
||||
|
||||
Reference in New Issue
Block a user