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 <jfd@butonic.de>
  • Loading branch information
butonic committed Mar 13, 2023
1 parent 39e8ddc commit 84be955
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
9 changes: 4 additions & 5 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 @@ -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 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 84be955

Please sign in to comment.