Fixed an issue with log files' name generation

It seems that on some specific file systems(?) `stat -c '%W' <file>`
returns `0` as a file creation timestamp
This commit is contained in:
Observer KRypt0n_ 2022-02-17 18:29:10 +02:00
parent 1c944a3d86
commit 505f8d16b8
No known key found for this signature in database
GPG key ID: 844DA47BA25FE1E2

View file

@ -28,7 +28,10 @@
constants.paths.launcherDir.then((launcherDir) => {
Neutralino.filesystem.getStats(`${launcherDir}/logs/latest.log`)
.then(async () => {
const created_at = (await Neutralino.os.execCommand(`stat -c '%W' "${path.addSlashes(`${launcherDir}/logs/latest.log`)}"`)).stdOut;
let created_at = (await Neutralino.os.execCommand(`stat -c '%W' "${path.addSlashes(`${launcherDir}/logs/latest.log`)}"`)).stdOut;
if (!created_at)
created_at = Date.now() / 1000;
Neutralino.filesystem.moveFile(`${launcherDir}/logs/latest.log`, `${launcherDir}/logs/${getLogFilename(new Date(created_at * 1000))}`);
})