forked from farhoodlabs/paperclip
Use fixed .tmp suffix for writeSettings temp file
The mutex already serializes all writes, so the PID-based temp name is unnecessary. A fixed suffix matches writeStore and avoids orphaned temp files after a crash (a restarted process picks a new PID). Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
@@ -111,7 +111,7 @@ function readSettings(): AdapterSettings {
|
||||
|
||||
function writeSettings(settings: AdapterSettings): void {
|
||||
ensureDirs();
|
||||
const tmpPath = `${ADAPTER_SETTINGS_PATH}.${process.pid}.tmp`;
|
||||
const tmpPath = `${ADAPTER_SETTINGS_PATH}.tmp`;
|
||||
fs.writeFileSync(tmpPath, JSON.stringify(settings, null, 2), "utf-8");
|
||||
fs.renameSync(tmpPath, ADAPTER_SETTINGS_PATH);
|
||||
settingsCache = settings;
|
||||
|
||||
Reference in New Issue
Block a user