diff --git a/CHANGELOG.md b/CHANGELOG.md index 3f755829b..3408c5bd0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -128,6 +128,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Remove user from tags when deleting user [#1161](https://github.com/greenbone/gvmd/pull/1161) - Handle INTERRUPTED scans [#1146](https://github.com/greenbone/gvmd/pull/1146) - Check hosts in MODIFY_OVERRIDE, as in CREATE_OVERRIDE [#1162](https://github.com/greenbone/gvmd/pull/1162) +- Preserve task "once" value [#1176](https://github.com/greenbone/gvmd/pull/1176) - Check number of args to ensure period_offsets is 0 [#1175](https://github.com/greenbone/gvmd/pull/1175) ### Removed diff --git a/src/gmp.c b/src/gmp.c index a545ebbd0..e5dea3182 100644 --- a/src/gmp.c +++ b/src/gmp.c @@ -16822,16 +16822,12 @@ get_task_schedule_xml (task_t task) "%d" "%s" "%s" - "" - "" - "%d" - "", + "", task_schedule_uuid, task_schedule_name, schedule_in_trash, icalendar ? icalendar : "", - zone ? zone : "", - task_schedule_periods (task)); + zone ? zone : ""); g_free (icalendar); g_free (zone); @@ -16848,6 +16844,12 @@ get_task_schedule_xml (task_t task) schedule_in_trash); } + xml_string_append (xml, + "" + "%d" + "", + task_schedule_periods (task)); + return g_string_free (xml, FALSE); } diff --git a/src/manage.c b/src/manage.c index e39e02767..41203eb4e 100644 --- a/src/manage.c +++ b/src/manage.c @@ -7111,7 +7111,7 @@ scheduled_task_start (scheduled_task_t *scheduled_task, * it from the task. If it has a duration it * will be removed by manage_schedule via * clear_duration_schedules, after the duration. */ - set_task_schedule_uuid (task_uuid, 0, 0); + set_task_schedule_uuid (task_uuid, 0, -1); else if ((periods = task_schedule_periods_uuid (task_uuid))) { diff --git a/src/manage_sql.c b/src/manage_sql.c index 6064e8443..a70292fc2 100644 --- a/src/manage_sql.c +++ b/src/manage_sql.c @@ -18234,27 +18234,35 @@ set_task_schedule (task_t task, schedule_t schedule, int periods) * * @param[in] task_id Task UUID. * @param[in] schedule Schedule. - * @param[in] periods Number of schedule periods. + * @param[in] periods Number of schedule periods. -1 to use existing value. * * @return 0 success, -1 error. */ int set_task_schedule_uuid (const gchar *task_id, schedule_t schedule, int periods) { - gchar *quoted_task_id; + gchar *quoted_task_id, *schedule_periods; + + if (periods == -1) + schedule_periods = g_strdup (""); + else + schedule_periods = g_strdup_printf ("schedule_periods = %i,", + periods); quoted_task_id = sql_quote (task_id); sql ("UPDATE tasks" " SET schedule = %llu," - " schedule_periods = %i," + "%s" " schedule_next_time = (SELECT next_time_ical (icalendar, timezone)" " FROM schedules" " WHERE id = %llu)," " modification_time = m_now ()" " WHERE uuid = '%s';", - schedule, periods, schedule, quoted_task_id); + schedule, schedule_periods, schedule, quoted_task_id); g_free (quoted_task_id); + g_free (schedule_periods); + return 0; }