From b1c27b588e6ad665d8b39c8368a2d10a2d77e7c4 Mon Sep 17 00:00:00 2001
From: Travis Ralston <travpc@gmail.com>
Date: Sun, 28 May 2023 17:52:22 -0600
Subject: [PATCH] Don't calculate blurhashes when we're not supposed to

---
 pipline/_steps/upload/blurhash_async.go | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/pipline/_steps/upload/blurhash_async.go b/pipline/_steps/upload/blurhash_async.go
index 1e665087..0e4056bb 100644
--- a/pipline/_steps/upload/blurhash_async.go
+++ b/pipline/_steps/upload/blurhash_async.go
@@ -12,11 +12,15 @@ import (
 
 func CalculateBlurhashAsync(ctx rcontext.RequestContext, reader io.Reader, sha256hash string) chan struct{} {
 	var err error
-	bhChan := make(chan struct{})
+	opChan := make(chan struct{})
 	go func() {
 		//goland:noinspection GoUnhandledErrorResult
 		defer io.Copy(io.Discard, reader) // we need to flush the reader as we might end up blocking the upload
-		defer close(bhChan)
+		defer close(opChan)
+
+		if !ctx.Config.Features.MSC2448Blurhash.Enabled {
+			return
+		}
 
 		var img image.Image
 		img, err = imaging.Decode(reader)
@@ -43,5 +47,5 @@ func CalculateBlurhashAsync(ctx rcontext.RequestContext, reader io.Reader, sha25
 			return
 		}
 	}()
-	return bhChan
+	return opChan
 }
-- 
GitLab