mirror of
https://github.com/getpaseo/paseo.git
synced 2026-11-21 07:45:38 +00:00
fix(skills): finish removing reachable skills during uninstall when one root is unreadable
Continue across every target root in `removeSkill` and every managed skill in `uninstallSkills` before throwing the first error (matching `syncSkills`), while still reporting `EACCES` rather than ignoring it.
This commit is contained in:
@@ -1323,6 +1323,16 @@ describe("skills controller", () => {
|
||||
} finally {
|
||||
await chmod(geminiHome, 0o755);
|
||||
}
|
||||
|
||||
// With ~/.gemini unreadable (0000), uninstall still removes every skill from healthy targets.
|
||||
await chmod(geminiHome, 0o000);
|
||||
try {
|
||||
await expect(harness.controller.uninstall()).rejects.toThrow();
|
||||
expect(await installedSkills(harness.targets.agentsDir)).toEqual([]);
|
||||
expect(await installedSkills(harness.targets.claudeDir)).toEqual([]);
|
||||
} finally {
|
||||
await chmod(geminiHome, 0o755);
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
@@ -259,11 +259,21 @@ export async function uninstallSkills(
|
||||
selection: SkillSelection,
|
||||
): Promise<SkillsStatus> {
|
||||
const available = await listBundledSkills(targets.sourceDir);
|
||||
let hasError = false;
|
||||
let firstError: unknown = null;
|
||||
for (const name of managedSkillNames(available)) {
|
||||
await removeSkill(name, {
|
||||
installDirs: targets.installDirs,
|
||||
codexDir: targets.codexDir,
|
||||
});
|
||||
try {
|
||||
await removeSkill(name, {
|
||||
installDirs: targets.installDirs,
|
||||
codexDir: targets.codexDir,
|
||||
});
|
||||
} catch (error) {
|
||||
if (!hasError) {
|
||||
hasError = true;
|
||||
firstError = error;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (hasError) throw firstError;
|
||||
return getSkillsStatus(targets, selection);
|
||||
}
|
||||
|
||||
@@ -178,13 +178,21 @@ export async function removeSkill(skillName: string, targets: RemoveSkillTargets
|
||||
const paths = [...targets.installDirs, targets.codexDir].map((root) =>
|
||||
path.join(root, skillName),
|
||||
);
|
||||
let hasError = false;
|
||||
let firstError: unknown = null;
|
||||
for (const p of paths) {
|
||||
await fs.rm(p, { recursive: true, force: true }).catch((error: NodeJS.ErrnoException) => {
|
||||
try {
|
||||
await fs.rm(p, { recursive: true, force: true });
|
||||
} catch (error) {
|
||||
// If an ancestor is a regular file, no skill directory can exist below it.
|
||||
if (error.code === "ENOTDIR") return;
|
||||
throw error;
|
||||
});
|
||||
if ((error as NodeJS.ErrnoException).code === "ENOTDIR") continue;
|
||||
if (!hasError) {
|
||||
hasError = true;
|
||||
firstError = error;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (hasError) throw firstError;
|
||||
}
|
||||
|
||||
async function isSameDirectory(a: string, b: string): Promise<boolean> {
|
||||
|
||||
Reference in New Issue
Block a user