mirror of
https://github.com/whyour/qinglong.git
synced 2026-07-01 04:40:38 +08:00
写入文件增加文件锁,避免竞争条件引起文件内容异常
This commit is contained in:
+2
-1
@@ -10,6 +10,7 @@ import { load } from 'js-yaml';
|
||||
import config from './index';
|
||||
import { TASK_COMMAND } from './const';
|
||||
import Logger from '../loaders/logger';
|
||||
import { writeFileWithLock } from '../shared/utils';
|
||||
|
||||
export * from './share';
|
||||
|
||||
@@ -170,7 +171,7 @@ export async function fileExist(file: any) {
|
||||
|
||||
export async function createFile(file: string, data: string = '') {
|
||||
await fs.mkdir(path.dirname(file), { recursive: true });
|
||||
await fs.writeFile(file, data);
|
||||
await writeFileWithLock(file, data);
|
||||
}
|
||||
|
||||
export async function handleLogPath(
|
||||
|
||||
Reference in New Issue
Block a user