Work around tasks with attachments not being duplicated
This commit is contained in:
parent
301bebf8d3
commit
a58b932743
1 changed files with 8 additions and 1 deletions
|
@ -111,6 +111,8 @@ func (ld *ListDuplicate) Create(a web.Auth) (err error) {
|
|||
return err
|
||||
}
|
||||
|
||||
// This map contains the old task id as key and the new duplicated task id as value.
|
||||
// It is used to map old task items to new ones.
|
||||
taskMap := make(map[int64]int64)
|
||||
// Create + update all tasks (includes reminders)
|
||||
oldTaskIDs := make([]int64, len(tasks))
|
||||
|
@ -143,7 +145,12 @@ func (ld *ListDuplicate) Create(a web.Auth) (err error) {
|
|||
for _, attachment := range attachments {
|
||||
oldAttachmentID := attachment.ID
|
||||
attachment.ID = 0
|
||||
attachment.TaskID = oldTaskIDs[attachment.TaskID]
|
||||
var exists bool
|
||||
attachment.TaskID, exists = taskMap[attachment.TaskID]
|
||||
if !exists {
|
||||
log.Debugf("Error duplicating attachment %d from old task %d to new task: Old task <-> new task does not seem to exist.", oldAttachmentID, attachment.TaskID)
|
||||
continue
|
||||
}
|
||||
attachment.File = &files.File{ID: attachment.FileID}
|
||||
if err := attachment.File.LoadFileMetaByID(); err != nil {
|
||||
if files.IsErrFileDoesNotExist(err) {
|
||||
|
|
Loading…
Reference in a new issue