Skip to content

Commit

Permalink
Write the manifest atomically to avoid corruption
Browse files Browse the repository at this point in the history
  • Loading branch information
IDCs committed Nov 19, 2024
1 parent a405a37 commit faf97bc
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/extensions/extension_manager/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -179,7 +180,7 @@ function downloadExtensionList(cachePath: string): Promise<IAvailableExtension[]
log('debug', 'extension list received');
return manifest.extensions.filter(ext => 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));
}

Expand Down

0 comments on commit faf97bc

Please sign in to comment.