fix(#5): clean up temp file when network data rename fails

This commit is contained in:
Josh Creek
2026-02-25 22:05:42 +00:00
parent 7bfab68d94
commit 69a5dedf67
@@ -134,7 +134,12 @@ export async function writeNetworkFile(data) {
} finally { } finally {
await fileHandle.close(); await fileHandle.close();
} }
try {
await rename(temporaryPath, source); await rename(temporaryPath, source);
} catch (renameError) {
await unlink(temporaryPath).catch(() => undefined);
throw renameError;
}
await trimBackups(backupDirectory, path.basename(source), 5); await trimBackups(backupDirectory, path.basename(source), 5);
const updatedAt = await readUpdatedAt(source); const updatedAt = await readUpdatedAt(source);