Skip to content

Commit

Permalink
Merge pull request #1176 from mattmundell/schedule-once-20.08
Browse files Browse the repository at this point in the history
Preserve task "once" value
  • Loading branch information
timopollmeier authored Jul 7, 2020
2 parents 6623d0d + 449d2a8 commit 5a51fb0
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 11 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 8 additions & 6 deletions src/gmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -16822,16 +16822,12 @@ get_task_schedule_xml (task_t task)
"<trash>%d</trash>"
"<icalendar>%s</icalendar>"
"<timezone>%s</timezone>"
"</schedule>"
"<schedule_periods>"
"%d"
"</schedule_periods>",
"</schedule>",
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);
Expand All @@ -16848,6 +16844,12 @@ get_task_schedule_xml (task_t task)
schedule_in_trash);
}

xml_string_append (xml,
"<schedule_periods>"
"%d"
"</schedule_periods>",
task_schedule_periods (task));

return g_string_free (xml, FALSE);
}

Expand Down
2 changes: 1 addition & 1 deletion src/manage.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
{
Expand Down
16 changes: 12 additions & 4 deletions src/manage_sql.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 5a51fb0

Please sign in to comment.