Skip to content

Commit

Permalink
make hound happy
Browse files Browse the repository at this point in the history
Signed-off-by: Jörn Friedrich Dreyer <[email protected]>
  • Loading branch information
butonic committed Mar 13, 2023
1 parent 39e8ddc commit d8636df
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
15 changes: 7 additions & 8 deletions pkg/storage/utils/decomposedfs/node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,8 +313,7 @@ func ReadNode(ctx context.Context, lu PathLookup, spaceID, nodeID string, canLis
n.ParentID = attrs.String(prefixes.ParentidAttr)
if n.ParentID == "" {
d, _ := os.ReadFile(lu.MetadataBackend().MetadataPath(n.InternalPath()))
switch lu.MetadataBackend().(type) {
case metadata.MessagePackBackend:
if _, ok := lu.MetadataBackend().(metadata.MessagePackBackend); ok {
appctx.GetLogger(ctx).Error().Str("nodeid", n.ID).Interface("attrs", attrs).Bytes("messagepack", d).Msg("missing parent id")
}
return nil, errtypes.InternalError("Missing parent ID on node")
Expand Down Expand Up @@ -467,7 +466,7 @@ func (n *Node) readOwner() (*userpb.UserId, error) {
attr, err = n.SpaceRoot.XattrString(prefixes.OwnerIDAttr)
switch {
case err == nil:
owner.OpaqueId = string(attr)
owner.OpaqueId = attr
case metadata.IsAttrUnset(err):
// ignore
default:
Expand All @@ -478,7 +477,7 @@ func (n *Node) readOwner() (*userpb.UserId, error) {
attr, err = n.SpaceRoot.XattrString(prefixes.OwnerIDPAttr)
switch {
case err == nil:
owner.Idp = string(attr)
owner.Idp = attr
case metadata.IsAttrUnset(err):
// ignore
default:
Expand All @@ -489,7 +488,7 @@ func (n *Node) readOwner() (*userpb.UserId, error) {
attr, err = n.SpaceRoot.XattrString(prefixes.OwnerTypeAttr)
switch {
case err == nil:
owner.Type = utils.UserTypeMap(string(attr))
owner.Type = utils.UserTypeMap(attr)
case metadata.IsAttrUnset(err):
// ignore
default:
Expand Down Expand Up @@ -843,7 +842,7 @@ func (n *Node) readChecksumIntoResourceChecksum(ctx context.Context, algo string
case err == nil:
ri.Checksum = &provider.ResourceChecksum{
Type: storageprovider.PKG2GRPCXS(algo),
Sum: hex.EncodeToString([]byte(v)),
Sum: hex.EncodeToString(v),
}
case metadata.IsAttrUnset(err):
appctx.GetLogger(ctx).Debug().Err(err).Str("nodepath", n.InternalPath()).Str("algorithm", algo).Msg("checksum not set")
Expand All @@ -863,7 +862,7 @@ func (n *Node) readChecksumIntoOpaque(ctx context.Context, algo string, ri *prov
}
ri.Opaque.Map[algo] = &types.OpaqueEntry{
Decoder: "plain",
Value: []byte(hex.EncodeToString([]byte(v))),
Value: []byte(hex.EncodeToString(v)),
}
case metadata.IsAttrUnset(err):
appctx.GetLogger(ctx).Debug().Err(err).Str("nodepath", n.InternalPath()).Str("algorithm", algo).Msg("checksum not set")
Expand Down Expand Up @@ -1107,7 +1106,7 @@ func (n *Node) ReadGrant(ctx context.Context, grantee string) (g *provider.Grant
return nil, err
}
var e *ace.ACE
if e, err = ace.Unmarshal(strings.TrimPrefix(grantee, prefixes.GrantPrefix), []byte(xattr)); err != nil {
if e, err = ace.Unmarshal(strings.TrimPrefix(grantee, prefixes.GrantPrefix), xattr); err != nil {
return nil, err
}
return e.Grant(), nil
Expand Down
5 changes: 5 additions & 0 deletions pkg/storage/utils/decomposedfs/node/xattrs.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,25 @@ import (
"github.com/pkg/xattr"
)

// Attributes is a map of string keys and byte array values
type Attributes map[string][]byte

// String reads a String value
func (md Attributes) String(key string) string {
return string(md[key])
}

// SetString sets a string value
func (md Attributes) SetString(key, val string) {
md[key] = []byte(val)
}

// Int64 reads an int64 value
func (md Attributes) Int64(key string) (int64, error) {
return strconv.ParseInt(string(md[key]), 10, 64)
}

// SetInt64 sets an int64 value
func (md Attributes) SetInt64(key string, val int64) {
md[key] = []byte(strconv.FormatInt(val, 10))
}
Expand Down

0 comments on commit d8636df

Please sign in to comment.