Only try to download attachments from todoist when there is a url

Credit: freaktechnik
This commit is contained in:
kolaente 2020-08-16 23:26:19 +02:00
parent d192c36c39
commit 301bebf8d3
No known key found for this signature in database
GPG key ID: F40E70337AB24C9B

View file

@ -316,6 +316,7 @@ func convertTodoistToVikunja(sync *sync) (fullVikunjaHierachie []*models.Namespa
} }
// Task Notes -> Task Descriptions // Task Notes -> Task Descriptions
// FIXME: Should be comments
for _, n := range sync.Notes { for _, n := range sync.Notes {
if tasks[n.ItemID].Description != "" { if tasks[n.ItemID].Description != "" {
tasks[n.ItemID].Description += "\n" tasks[n.ItemID].Description += "\n"
@ -326,6 +327,8 @@ func convertTodoistToVikunja(sync *sync) (fullVikunjaHierachie []*models.Namespa
continue continue
} }
// Only add the attachment if there's something to download
if len(n.FileAttachment.FileURL) > 0 {
// Download the attachment and put it in the file // Download the attachment and put it in the file
resp, err := http.Get(n.FileAttachment.FileURL) resp, err := http.Get(n.FileAttachment.FileURL)
if err != nil { if err != nil {
@ -352,6 +355,7 @@ func convertTodoistToVikunja(sync *sync) (fullVikunjaHierachie []*models.Namespa
Created: n.Posted, Created: n.Posted,
}) })
} }
}
// Project Notes -> List Descriptions // Project Notes -> List Descriptions
for _, pn := range sync.ProjectNotes { for _, pn := range sync.ProjectNotes {