Skip to content

Commit a518ef8

Browse files
SC-ClawSC-Claw
authored andcommitted
Daemon: clean up trusted launchd plist path handling
1 parent e3c42b5 commit a518ef8

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

src/daemon/launchd.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ function resolveLaunchAgentLabel(args?: { env?: Record<string, string | undefine
6161
}
6262

6363
function resolveLaunchAgentPlistPathForLabel(
64-
env: Record<string, string | undefined>,
64+
_env: Record<string, string | undefined>,
6565
label: string,
6666
): string {
6767
const home = resolveTrustedLaunchAgentHome();
@@ -285,7 +285,12 @@ async function writeLaunchAgentPlistSecure(plistPath: string, plist: string): Pr
285285
throw error;
286286
}
287287
await handle.close();
288-
await fs.rename(tempPath, plistPath);
288+
try {
289+
await fs.rename(tempPath, plistPath);
290+
} catch (error) {
291+
await fs.unlink(tempPath).catch(() => undefined);
292+
throw error;
293+
}
289294
}
290295

291296
export type LaunchctlPrintInfo = {

0 commit comments

Comments
 (0)