diff --git a/pipelines/_steps/upload/blurhash_async.go b/pipelines/_steps/upload/blurhash_async.go index ba9d57a22d503a3e9ae8e96facbb6634c2d16844..d44a53c63b0d2e2798227b39067464148a7724eb 100644 --- a/pipelines/_steps/upload/blurhash_async.go +++ b/pipelines/_steps/upload/blurhash_async.go @@ -10,7 +10,7 @@ import ( "github.com/turt2live/matrix-media-repo/database" ) -func CalculateBlurhashAsync(ctx rcontext.RequestContext, reader io.Reader, sha256hash string) chan struct{} { +func CalculateBlurhashAsync(ctx rcontext.RequestContext, reader io.Reader, sizeBytes int64, sha256hash string) chan struct{} { var err error opChan := make(chan struct{}) go func() { @@ -21,6 +21,9 @@ func CalculateBlurhashAsync(ctx rcontext.RequestContext, reader io.Reader, sha25 if !ctx.Config.Features.MSC2448Blurhash.Enabled { return } + if ctx.Config.Thumbnails.MaxSourceBytes <= sizeBytes { + return + } var img image.Image img, err = imaging.Decode(reader) diff --git a/pipelines/pipeline_upload/pipeline.go b/pipelines/pipeline_upload/pipeline.go index ba53322e3a8caeb6977126fa9aa43ca9c2ecdbec..66105d7d1778e8301b70d254f953e901cea85b2b 100644 --- a/pipelines/pipeline_upload/pipeline.go +++ b/pipelines/pipeline_upload/pipeline.go @@ -150,7 +150,7 @@ func Execute(ctx rcontext.RequestContext, origin string, mediaId string, r io.Re } // Step 10: Asynchronously calculate blurhash - bhChan := upload.CalculateBlurhashAsync(ctx, bhR, sha256hash) + bhChan := upload.CalculateBlurhashAsync(ctx, bhR, sizeBytes, sha256hash) // Step 11: Asynchronously upload to cache cacheChan := upload.PopulateCacheAsync(ctx, cacheR, sizeBytes, sha256hash)