mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 18:10:45 +00:00
fix: skip compile cache permission warnings (#76362) (thanks @neeravmakwana)
This commit is contained in:
@@ -147,6 +147,57 @@ describe("bundled plugin postinstall", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("does not warn when compile-cache pruning hits EACCES or EPERM (shared caches)", () => {
|
||||
const base = path.join("/tmp", "openclaw-shared-compile-cache");
|
||||
const dirA = path.join(base, "v22.13.1-x64-efe9a9df-1001");
|
||||
const dirB = path.join(base, "v22.13.1-x64-efe9a9df-1002");
|
||||
const warn = vi.fn();
|
||||
const rmSync = vi.fn((value: string) => {
|
||||
if (value === dirA) {
|
||||
throw Object.assign(new Error(`permission denied pruning ${value}`), { code: "EACCES" });
|
||||
}
|
||||
if (value === dirB) {
|
||||
throw Object.assign(new Error(`operation not permitted pruning ${value}`), {
|
||||
code: "EPERM",
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
pruneOpenClawCompileCache({
|
||||
env: { NODE_COMPILE_CACHE: base },
|
||||
existsSync: vi.fn((value: string) => value === base),
|
||||
readdirSync: vi.fn(() => [
|
||||
{ name: path.basename(dirA), isDirectory: () => true },
|
||||
{ name: path.basename(dirB), isDirectory: () => true },
|
||||
]),
|
||||
rmSync,
|
||||
log: { warn },
|
||||
});
|
||||
|
||||
expect(rmSync).toHaveBeenCalledTimes(2);
|
||||
expect(warn).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("does not warn when the compile-cache base directory cannot be listed (EACCES)", () => {
|
||||
const base = path.join("/tmp", "openclaw-compile-cache-no-list");
|
||||
const warn = vi.fn();
|
||||
const rmSync = vi.fn();
|
||||
const err = Object.assign(new Error(`EACCES: ${base}`), { code: "EACCES" });
|
||||
|
||||
pruneOpenClawCompileCache({
|
||||
env: { NODE_COMPILE_CACHE: base },
|
||||
existsSync: vi.fn(() => true),
|
||||
readdirSync: vi.fn(() => {
|
||||
throw err;
|
||||
}),
|
||||
rmSync,
|
||||
log: { warn },
|
||||
});
|
||||
|
||||
expect(rmSync).not.toHaveBeenCalled();
|
||||
expect(warn).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("does not classify published packages with source files as source checkouts", () => {
|
||||
const packageRoot = "/pkg";
|
||||
const existingPaths = new Set([
|
||||
|
||||
Reference in New Issue
Block a user