diff --git a/controllers/download_controller/download_controller.go b/controllers/download_controller/download_controller.go index 7dae57d7c6de90c28a06b93f4afce5c6a459f9d3..4cf85eec4cc85fc7c99fc8f7d2b62518494e851c 100644 --- a/controllers/download_controller/download_controller.go +++ b/controllers/download_controller/download_controller.go @@ -130,7 +130,12 @@ func GetMedia(origin string, mediaId string, downloadRemote bool, blockForMedia return vals }) - return v.(*types.MinimalMedia), err + var value *types.MinimalMedia + if v != nil { + value = v.(*types.MinimalMedia) + } + + return value, err } func FindMinimalMediaRecord(origin string, mediaId string, downloadRemote bool, ctx context.Context, log *logrus.Entry) (*types.MinimalMedia, error) { @@ -258,5 +263,10 @@ func FindMediaRecord(origin string, mediaId string, downloadRemote bool, ctx con return media, nil }) - return v.(*types.Media), err + var value *types.Media + if v != nil { + value = v.(*types.Media) + } + + return value, err } diff --git a/controllers/preview_controller/preview_controller.go b/controllers/preview_controller/preview_controller.go index 82c7b6006af65fd99dd200a59574494228c5d6c0..2c32758a0547148ac35a1da11bba28c1d738e4bb 100644 --- a/controllers/preview_controller/preview_controller.go +++ b/controllers/preview_controller/preview_controller.go @@ -59,7 +59,12 @@ func GetPreview(urlStr string, onHost string, forUserId string, atTs int64, ctx return result.preview, result.err }) - return v.(*types.UrlPreview), err + var value *types.UrlPreview + if v != nil { + value = v.(*types.UrlPreview) + } + + return value, err } func cachedPreviewToReal(cached *types.CachedUrlPreview) (*types.UrlPreview, error) { diff --git a/controllers/thumbnail_controller/thumbnail_controller.go b/controllers/thumbnail_controller/thumbnail_controller.go index 3c9a321946a2688f60bfd8d43b3ab9e975ef9b51..e91f954ae6376cb72168ef386686cc046eea2d98 100644 --- a/controllers/thumbnail_controller/thumbnail_controller.go +++ b/controllers/thumbnail_controller/thumbnail_controller.go @@ -193,7 +193,12 @@ func GetThumbnail(origin string, mediaId string, desiredWidth int, desiredHeight return vals }) - return v.(*types.StreamedThumbnail), err + var value *types.StreamedThumbnail + if v != nil { + value = v.(*types.StreamedThumbnail) + } + + return value, err } func GetOrGenerateThumbnail(media *types.Media, width int, height int, animated bool, method string, ctx context.Context, log *logrus.Entry) (*types.Thumbnail, error) {