fix parsing of cron pattern

in some old instances, we had "00 00  * * *" (note double space
and only 5 components).
This commit is contained in:
Girish Ramakrishnan
2025-11-18 09:58:38 +01:00
parent 2cb7b4d1ea
commit c5f97e8bb0
4 changed files with 63 additions and 71 deletions
@@ -3,7 +3,7 @@
import { ref, useTemplateRef, computed } from 'vue';
import { Radiobutton, Dialog, FormGroup, SingleSelect, MultiSelect } from '@cloudron/pankow';
import BackupSitesModel from '../models/BackupSitesModel.js';
import { cronDays, cronHours } from '../utils.js';
import { cronDays, cronHours, parseSchedule } from '../utils.js';
const emit = defineEmits([ 'success' ]);
@@ -76,16 +76,9 @@ defineExpose({
scheduleType.value = 'never';
} else {
scheduleType.value = 'pattern';
const tmp = site.value.schedule.split(' ');
const tmpHours = tmp[2].split(',');
const tmpDays = tmp[5].split(',');
if (tmpDays[0] === '*') days.value = cronDays.map((day) => { return day.id; });
else days.value = tmpDays.map((day) => { return parseInt(day, 10); });
if (tmpHours[0] === '*') hours.value = cronHours.map(h => h.id);
else hours.value = tmpHours.map((hour) => { return parseInt(hour, 10); });
const result = parseSchedule(site.value.schedule);
days.value = result.days; // Array of cronDays.id
hours.value = result.hours; // Array of cronHours.id
}
dialog.value.open();