diff --git a/db/integrations/komoot/komoot.go b/db/integrations/komoot/komoot.go index 4547778b..65f8bebd 100644 --- a/db/integrations/komoot/komoot.go +++ b/db/integrations/komoot/komoot.go @@ -405,9 +405,9 @@ func fetchRoutePhotos(k *KomootApi, tour *DetailedKomootTour) ([]*filesystem.Fil return nil, err } - photos := make([]*filesystem.File, data.Page.TotalElements) + photos := make([]*filesystem.File, 0, len(data.Embedded.Items)) - for i, img := range data.Embedded.Items { + for _, img := range data.Embedded.Items { photo, err := fetchPhoto(img.Src, "", "") if err != nil { return nil, err @@ -415,7 +415,7 @@ func fetchRoutePhotos(k *KomootApi, tour *DetailedKomootTour) ([]*filesystem.Fil if strings.HasSuffix(photo.Name, ".gif") { continue } - photos[i] = photo + photos = append(photos, photo) //TODO: komoot photos can have location data. Maybe we should create a waypoint for those photos? } @@ -425,9 +425,9 @@ func fetchRoutePhotos(k *KomootApi, tour *DetailedKomootTour) ([]*filesystem.Fil func fetchWaypointPhotos(wp Item) ([]*filesystem.File, error) { - photos := make([]*filesystem.File, len(wp.Embedded.Reference.Embedded.Images.Embedded.Items)) + photos := make([]*filesystem.File, 0, len(wp.Embedded.Reference.Embedded.Images.Embedded.Items)) - for i, img := range wp.Embedded.Reference.Embedded.Images.Embedded.Items { + for _, img := range wp.Embedded.Reference.Embedded.Images.Embedded.Items { photo, err := fetchPhoto(img.Src, "", "") if err != nil { return nil, err @@ -435,7 +435,7 @@ func fetchWaypointPhotos(wp Item) ([]*filesystem.File, error) { if strings.HasSuffix(photo.Name, ".gif") { continue } - photos[i] = photo + photos = append(photos, photo) } return photos, nil