fix komoot integration issue with 'invalid' photos (#941)
This commit is contained in:
@@ -405,9 +405,9 @@ func fetchRoutePhotos(k *KomootApi, tour *DetailedKomootTour) ([]*filesystem.Fil
|
|||||||
return nil, err
|
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, "", "")
|
photo, err := fetchPhoto(img.Src, "", "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -415,7 +415,7 @@ func fetchRoutePhotos(k *KomootApi, tour *DetailedKomootTour) ([]*filesystem.Fil
|
|||||||
if strings.HasSuffix(photo.Name, ".gif") {
|
if strings.HasSuffix(photo.Name, ".gif") {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
photos[i] = photo
|
photos = append(photos, photo)
|
||||||
|
|
||||||
//TODO: komoot photos can have location data. Maybe we should create a waypoint for those photos?
|
//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) {
|
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, "", "")
|
photo, err := fetchPhoto(img.Src, "", "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -435,7 +435,7 @@ func fetchWaypointPhotos(wp Item) ([]*filesystem.File, error) {
|
|||||||
if strings.HasSuffix(photo.Name, ".gif") {
|
if strings.HasSuffix(photo.Name, ".gif") {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
photos[i] = photo
|
photos = append(photos, photo)
|
||||||
}
|
}
|
||||||
|
|
||||||
return photos, nil
|
return photos, nil
|
||||||
|
|||||||
Reference in New Issue
Block a user