Fix: Maintenance: Handle optional startDateTime to prevent errors when null (#6189)
This commit is contained in:
parent
e6f105535f
commit
2d50d68da0
@ -263,7 +263,7 @@ class Maintenance extends BeanModel {
|
|||||||
|
|
||||||
// Set last start date to current time
|
// Set last start date to current time
|
||||||
this.last_start_date = current.toISOString();
|
this.last_start_date = current.toISOString();
|
||||||
R.store(this);
|
await R.store(this);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Create Cron
|
// Create Cron
|
||||||
@ -272,9 +272,16 @@ class Maintenance extends BeanModel {
|
|||||||
const startDate = dayjs(this.startDate);
|
const startDate = dayjs(this.startDate);
|
||||||
const [ hour, minute ] = this.startTime.split(":");
|
const [ hour, minute ] = this.startTime.split(":");
|
||||||
const startDateTime = startDate.hour(hour).minute(minute);
|
const startDateTime = startDate.hour(hour).minute(minute);
|
||||||
|
|
||||||
|
// Fix #6118, since the startDateTime is optional, it will throw error if the date is null when using toISOString()
|
||||||
|
let startAt = undefined;
|
||||||
|
try {
|
||||||
|
startAt = startDateTime.toISOString();
|
||||||
|
} catch (_) {}
|
||||||
|
|
||||||
this.beanMeta.job = new Cron(this.cron, {
|
this.beanMeta.job = new Cron(this.cron, {
|
||||||
timezone: await this.getTimezone(),
|
timezone: await this.getTimezone(),
|
||||||
startAt: startDateTime.toISOString(),
|
startAt,
|
||||||
}, () => {
|
}, () => {
|
||||||
if (!this.lastStartDate || this.interval_day === 1) {
|
if (!this.lastStartDate || this.interval_day === 1) {
|
||||||
return startEvent();
|
return startEvent();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user