From faf97bc8795f004100a2b6995b98afd924efa80f Mon Sep 17 00:00:00 2001 From: IDCs Date: Tue, 19 Nov 2024 11:57:15 +0000 Subject: [PATCH] Write the manifest atomically to avoid corruption --- src/extensions/extension_manager/util.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/extensions/extension_manager/util.ts b/src/extensions/extension_manager/util.ts index 5ae30a549..bcd3948ab 100644 --- a/src/extensions/extension_manager/util.ts +++ b/src/extensions/extension_manager/util.ts @@ -2,6 +2,7 @@ import { IExtensionApi } from '../../types/IExtensionContext'; import { IDownload, IState } from '../../types/IState'; import { DataInvalid, ProcessCanceled, ServiceTemporarilyUnavailable, UserCanceled } from '../../util/CustomErrors'; import * as fs from '../../util/fs'; +import { writeFileAtomic } from '../../util/fsAtomic'; import getVortexPath from '../../util/getVortexPath'; import { log } from '../../util/log'; import { jsonRequest, rawRequest } from '../../util/network'; @@ -179,7 +180,7 @@ function downloadExtensionList(cachePath: string): Promise ext.name !== undefined); }) - .tap(extensions => fs.writeFileAsync(cachePath, JSON.stringify({ extensions }, undefined, 2), { encoding: 'utf8' })) + .tap(extensions => writeFileAtomic(cachePath, JSON.stringify({ extensions }, undefined, 2))) .tapCatch(err => log('error', 'failed to download extension list', err)); }