From 859654d2de1782e4a06ff9b103d26db98ca91d00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Friedrich=20Dreyer?= Date: Fri, 1 Jul 2022 11:29:25 +0000 Subject: [PATCH] storageprovidercache: use stringbuffer to build statKey MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jörn Friedrich Dreyer --- .../services/gateway/storageprovidercache.go | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/internal/grpc/services/gateway/storageprovidercache.go b/internal/grpc/services/gateway/storageprovidercache.go index c72c6b0a1d5..978006fd324 100644 --- a/internal/grpc/services/gateway/storageprovidercache.go +++ b/internal/grpc/services/gateway/storageprovidercache.go @@ -234,15 +234,25 @@ func statKey(user *userpb.User, ref *provider.Reference, metaDataKeys, fieldMask return "" } - key := "uid:" + user.Id.OpaqueId + "!sid:" + ref.ResourceId.StorageId + "!oid:" + ref.ResourceId.OpaqueId + "!path:" + ref.Path + key := strings.Builder{} + key.WriteString("uid:") + key.WriteString(user.Id.OpaqueId) + key.WriteString("!sid:") + key.WriteString(ref.ResourceId.StorageId) + key.WriteString("!oid:") + key.WriteString(ref.ResourceId.OpaqueId) + key.WriteString("!path:") + key.WriteString(ref.Path) for _, k := range metaDataKeys { - key += "!mdk:" + k + key.WriteString("!mdk:") + key.WriteString(k) } for _, p := range fieldMaskPaths { - key += "!fmp:" + p + key.WriteString("!fmp:") + key.WriteString(p) } - return key + return key.String() } // Stat looks in cache first before forwarding to storage provider