mirror of
https://github.com/finos/SymphonyElectron.git
synced 2025-02-25 18:55:29 -06:00
SDA-2875: add defense for statSync in logger (#1173)
This commit is contained in:
parent
2c947ed41c
commit
63d719b3b5
@ -251,10 +251,12 @@ class Logger {
|
|||||||
const deleteTimeStamp = new Date().getTime() - (5 * 24 * 60 * 60 * 1000);
|
const deleteTimeStamp = new Date().getTime() - (5 * 24 * 60 * 60 * 1000);
|
||||||
files.forEach((file) => {
|
files.forEach((file) => {
|
||||||
const filePath = path.join(this.logPath, file);
|
const filePath = path.join(this.logPath, file);
|
||||||
const stat = fs.statSync(filePath);
|
if (fs.existsSync(filePath)) {
|
||||||
const fileTimestamp = new Date(util.inspect(stat.mtime)).getTime();
|
const stat = fs.statSync(filePath);
|
||||||
if ((fileTimestamp < deleteTimeStamp) && fs.existsSync(filePath)) {
|
const fileTimestamp = new Date(util.inspect(stat.mtime)).getTime();
|
||||||
fs.unlinkSync(filePath);
|
if ((fileTimestamp < deleteTimeStamp)) {
|
||||||
|
fs.unlinkSync(filePath);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user