From ce8cdac7c7eaa4a968c63fd5138b77cebab9c098 Mon Sep 17 00:00:00 2001 From: mercury Date: Fri, 25 Oct 2024 18:36:54 +0400 Subject: [PATCH] Fix for auto-backup not triggering on the first tick --- app/bot.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/app/bot.php b/app/bot.php index 7a13f75..7ecb7e4 100644 --- a/app/bot.php +++ b/app/bot.php @@ -1066,17 +1066,18 @@ class Bot public function cron() { + $period = 10; while (true) { $this->shutdownClient(); $this->shutdownClientXr(); $this->checkVersion(); - $this->checkBackup(); + $this->checkBackup($period); $this->checkCert(); - sleep(10); + sleep($period); } } - public function checkBackup() + public function checkBackup($delta) { $c = $this->getPacConf(); if (!empty($c['backup'])) { @@ -1088,8 +1089,8 @@ class Bot !empty($start) && !empty($period) && empty($this->backup) - && $now - $start >= $period - && ($now - $start) % $period < 10 + && $now - $start >= 0 + && (($now - $start) % $period < $delta) ) { if (!empty($c['pinbackup'])) { $this->pinAdmin($c['pinbackup'], 1);