Always reinstall cron when saving a schedule

Previously the cron was only updated if it was already active.
Now every save reinstalls the cron entry so changes (like enabling
--sysbackup) take effect immediately.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
shuki
2026-03-04 17:36:20 +02:00
parent 3547b00ead
commit 0da580666c

View File

@@ -252,11 +252,8 @@ sub handle_edit {
if (!@errors) { if (!@errors) {
my ($ok, $err) = GnizaWHM::Config::write($conf_path, \%data, \@GnizaWHM::Config::SCHEDULE_KEYS); my ($ok, $err) = GnizaWHM::Config::write($conf_path, \%data, \@GnizaWHM::Config::SCHEDULE_KEYS);
if ($ok) { if ($ok) {
# Re-install cron if it was active, so timing/remote changes take effect # Always reinstall cron so changes take effect immediately
my $cron_schedules = GnizaWHM::Cron::get_current_schedules();
if (exists $cron_schedules->{$name}) {
GnizaWHM::Cron::install_schedule($name); GnizaWHM::Cron::install_schedule($name);
}
GnizaWHM::UI::set_flash('success', "Schedule '$name' updated successfully."); GnizaWHM::UI::set_flash('success', "Schedule '$name' updated successfully.");
print "Status: 302 Found\r\n"; print "Status: 302 Found\r\n";
print "Location: schedules.cgi\r\n\r\n"; print "Location: schedules.cgi\r\n\r\n";