Use atomic write
This commit is contained in:
parent
01ccc32274
commit
cbedfa4664
|
@ -5,6 +5,7 @@ const fetch = require('node-fetch').default;
|
|||
const sanitize = require('sanitize-filename');
|
||||
const { getConfigValue } = require('../util');
|
||||
const { jsonParser } = require('../express-common');
|
||||
const writeFileAtomicSync = require('write-file-atomic').sync;
|
||||
const contentDirectory = path.join(process.cwd(), 'default/content');
|
||||
const contentIndexPath = path.join(contentDirectory, 'index.json');
|
||||
const characterCardParser = require('../character-card-parser.js');
|
||||
|
@ -133,7 +134,7 @@ async function seedContentForUser(contentIndex, directories, forceCategories) {
|
|||
console.log(`Content file ${contentItem.filename} copied to ${contentTarget}`);
|
||||
}
|
||||
|
||||
fs.writeFileSync(contentLogPath, contentLog.join('\n'));
|
||||
writeFileAtomicSync(contentLogPath, contentLog.join('\n'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
const commandExistsSync = require('command-exists').sync;
|
||||
const writeFileAtomicSync = require('write-file-atomic').sync;
|
||||
const _ = require('lodash');
|
||||
const yauzl = require('yauzl');
|
||||
const mime = require('mime-types');
|
||||
|
@ -61,7 +62,7 @@ function setConfigValue(key, value) {
|
|||
CACHED_CONFIG = null;
|
||||
const config = getConfig();
|
||||
_.set(config, key, value);
|
||||
fs.writeFileSync('./config.yaml', yaml.stringify(config));
|
||||
writeFileAtomicSync('./config.yaml', yaml.stringify(config));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue