fix(caldav): do not update dates of tasks when repositioning them (#1605)

When a task is updated, the position of the tasks of the whole project/bucket are updated. This leads to column "updated" of model Task to be updated quite often. However, that column is used for the ETag field of CALDAV.
Thus, changing a task marks all the other tasks as updated, which prevents clients from synchronizing their edited tasks.

Co-authored-by: Erwan Martin <erwan@pepper.com>
Reviewed-on: vikunja/api#1605
Co-authored-by: Erwan Martin <public@fzwte.net>
Co-committed-by: Erwan Martin <public@fzwte.net>
This commit is contained in:
Erwan Martin 2023-09-27 16:17:52 +00:00 committed by konrad
parent f065dcf4ad
commit feacbbff74
1 changed files with 10 additions and 0 deletions

View File

@ -1081,8 +1081,13 @@ func recalculateTaskKanbanPositions(s *xorm.Session, bucketID int64) (err error)
currentPosition := maxPosition / float64(len(allTasks)) * (float64(i + 1))
// Here we use "NoAutoTime() to prevent the ORM from updating column "updated" automatically.
// Otherwise, this signals to CalDAV clients that the task has changed, which is not the case.
// Consequence: when synchronizing a list of tasks, the first one immediately changes the date of all the
// following ones from the same batch, which are then unable to be updated.
_, err = s.Cols("kanban_position").
Where("id = ?", task.ID).
NoAutoTime().
Update(&Task{KanbanPosition: currentPosition})
if err != nil {
return
@ -1109,8 +1114,13 @@ func recalculateTaskPositions(s *xorm.Session, projectID int64) (err error) {
currentPosition := maxPosition / float64(len(allTasks)) * (float64(i + 1))
// Here we use "NoAutoTime() to prevent the ORM from updating column "updated" automatically.
// Otherwise, this signals to CalDAV clients that the task has changed, which is not the case.
// Consequence: when synchronizing a list of tasks, the first one immediately changes the date of all the
// following ones from the same batch, which are then unable to be updated.
_, err = s.Cols("position").
Where("id = ?", task.ID).
NoAutoTime().
Update(&Task{Position: currentPosition})
if err != nil {
return