Skip to content

Commit

Permalink
storageprovidercache: use stringbuffer to build statKey
Browse files Browse the repository at this point in the history
Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
  • Loading branch information
butonic committed Jul 6, 2022
1 parent 758715a commit b90148e
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions internal/grpc/services/gateway/storageprovidercache.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b90148e

Please sign in to comment.