Perform safeRename on writeFileAtomic

This forces a sync of the file as soon as the rename happens to prevent
corruption.
This commit is contained in:
Felipe Lalanne 2022-01-25 17:05:04 -03:00
parent c5670ba366
commit a0ed00d8f3

View File

@ -27,7 +27,7 @@ export async function writeFileAtomic(
data: string | Buffer,
): Promise<void> {
await writeAndSyncFile(`${pathName}.new`, data);
await fs.rename(`${pathName}.new`, pathName);
await safeRename(`${pathName}.new`, pathName);
}
export async function safeRename(src: string, dest: string): Promise<void> {