mirror of
https://github.com/whyour/qinglong.git
synced 2025-07-07 11:56:08 +08:00
修复清空文件夹报错
This commit is contained in:
parent
b8a9b26ca3
commit
26b06c17c5
|
@ -309,7 +309,7 @@ export async function emptyDir(path: string) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const files = fs.readdirSync(path);
|
const files = fs.readdirSync(path);
|
||||||
files.forEach(async (file) => {
|
for (const file of files) {
|
||||||
const filePath = `${path}/${file}`;
|
const filePath = `${path}/${file}`;
|
||||||
const stats = fs.statSync(filePath);
|
const stats = fs.statSync(filePath);
|
||||||
if (stats.isDirectory()) {
|
if (stats.isDirectory()) {
|
||||||
|
@ -317,7 +317,7 @@ export async function emptyDir(path: string) {
|
||||||
} else {
|
} else {
|
||||||
fs.unlinkSync(filePath);
|
fs.unlinkSync(filePath);
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
fs.rmdirSync(path);
|
fs.rmdirSync(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,13 +30,9 @@ export default async ({ server }: { server: Server }) => {
|
||||||
|
|
||||||
process.on('uncaughtException', (error) => {
|
process.on('uncaughtException', (error) => {
|
||||||
Logger.error('Uncaught exception:', error);
|
Logger.error('Uncaught exception:', error);
|
||||||
console.error('Uncaught exception:', error);
|
|
||||||
process.exit(1);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
process.on('unhandledRejection', (reason, promise) => {
|
process.on('unhandledRejection', (reason, promise) => {
|
||||||
Logger.error('Unhandled rejection:', reason, promise);
|
Logger.error('Unhandled rejection:', reason, promise);
|
||||||
console.error('Unhandled rejection:', reason, promise);
|
|
||||||
process.exit(1);
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue
Block a user