initialize last mtime with actual fs value

This commit is contained in:
soffee 2026-01-27 02:09:37 +03:00
parent 10f430592d
commit c90c0c6688
2 changed files with 3 additions and 7 deletions

View file

@ -1,7 +1,7 @@
{ {
"name": "mtproto_exporter", "name": "mtproto_exporter",
"type": "module", "type": "module",
"version": "1.5.1", "version": "1.5.2",
"packageManager": "pnpm@10.6.5", "packageManager": "pnpm@10.6.5",
"license": "MIT", "license": "MIT",
"scripts": { "scripts": {

View file

@ -62,18 +62,14 @@ if (config.keywords) {
} }
}; };
let lastMtimeMs = 0; let lastMtimeMs = (await fs.promises.stat(config.keywordsFile)).mtimeMs;
setInterval(async () => { setInterval(async () => {
const stat = await fs.promises.stat(config.keywordsFile); const stat = await fs.promises.stat(config.keywordsFile);
if (lastMtimeMs === stat.mtimeMs) { if (lastMtimeMs === stat.mtimeMs) {
return; return;
} }
if (lastMtimeMs === 0 && stat.mtimeMs !== 0) {
lastMtimeMs = stat.mtimeMs;
return;
}
lastMtimeMs = stat.mtimeMs; lastMtimeMs = stat.mtimeMs;
console.log("[watch-file] Keywords file was updated. Reloading keywords configuration..."); console.log("[watch-file] Keywords file was updated. Reloading keywords configuration...");