Skip to content

Commit

Permalink
remove error debug, save some locks
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 9, 2023
1 parent 607bac0 commit 144d26e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 20 deletions.
4 changes: 1 addition & 3 deletions pkg/storage/utils/decomposedfs/node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,6 @@ func (n *Node) WriteAllNodeMetadata(ctx context.Context) (err error) {
attribs[prefixes.BlobIDAttr] = n.BlobID
attribs[prefixes.BlobsizeAttr] = strconv.FormatInt(n.Blobsize, 10)

appctx.GetLogger(ctx).Error().Str("nodeid", n.ID).Str("parentid", n.ParentID).Msg("Setting parent id")
return n.SetXattrs(attribs, true)
}

Expand Down Expand Up @@ -316,9 +315,8 @@ func ReadNode(ctx context.Context, lu PathLookup, spaceID, nodeID string, canLis
n.Name = attrs[prefixes.NameAttr]
n.ParentID = attrs[prefixes.ParentidAttr]
if n.ParentID == "" {
appctx.GetLogger(ctx).Error().Str("nodeid", n.ID).Str("parentid", n.ParentID).Interface("attrs", attrs).Msg("missing parent id")
d, _ := os.ReadFile(n.InternalPath() + ".ini")
appctx.GetLogger(ctx).Error().Str("ini", string(d)).Msg("missing parent id")
appctx.GetLogger(ctx).Error().Str("nodeid", n.ID).Str("parentid", n.ParentID).Interface("attrs", attrs).Str("ini", string(d)).Msg("missing parent id")
return nil, errtypes.InternalError("Missing parent ID on node")
}
// TODO why do we stat the parent? to determine if the current node is in the trash we would need to traverse all parents...
Expand Down
30 changes: 15 additions & 15 deletions pkg/storage/utils/decomposedfs/tree/tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -387,12 +387,11 @@ func (t *Tree) Move(ctx context.Context, oldNode *node.Node, newNode *node.Node)
}

// update target parentid and name
appctx.GetLogger(ctx).Error().Str("nodeid", oldNode.ID).Str("parentid", newNode.ParentID).Msg("Setting parent id11111")
if err := oldNode.SetXattr(prefixes.ParentidAttr, newNode.ParentID); err != nil {
return errors.Wrap(err, "Decomposedfs: could not set parentid attribute")
}
if err := oldNode.SetXattr(prefixes.NameAttr, newNode.Name); err != nil {
return errors.Wrap(err, "Decomposedfs: could not set name attribute")
if err := oldNode.SetXattrs(map[string]string{
prefixes.ParentidAttr: newNode.ParentID,
prefixes.NameAttr: newNode.Name,
}, true); err != nil {
return errors.Wrap(err, "Decomposedfs: could not update old node attributes")
}

// the size diff is the current treesize or blobsize of the old/source node
Expand Down Expand Up @@ -618,17 +617,18 @@ func (t *Tree) RestoreRecycleItemFunc(ctx context.Context, spaceid, key, trashPa
}

targetNode.Exists = true
// update name attribute
if err := recycleNode.SetXattr(prefixes.NameAttr, targetNode.Name); err != nil {
return errors.Wrap(err, "Decomposedfs: could not set name attribute")
}

// set ParentidAttr to restorePath's node parent id
attrs := map[string]string{
// update name attribute
prefixes.NameAttr: targetNode.Name,
}
if trashPath != "" {
appctx.GetLogger(ctx).Error().Str("nodeid", recycleNode.ID).Str("parentid", targetNode.ParentID).Msg("Setting parent id22222222")
if err := recycleNode.SetXattr(prefixes.ParentidAttr, targetNode.ParentID); err != nil {
return errors.Wrap(err, "Decomposedfs: could not set name attribute")
}
// set ParentidAttr to restorePath's node parent id
attrs[prefixes.ParentidAttr] = targetNode.ParentID
}

if err = recycleNode.SetXattrs(attrs, true); err != nil {
return errors.Wrap(err, "Decomposedfs: could not update recycle node")
}

// delete item link in trash
Expand Down
3 changes: 1 addition & 2 deletions pkg/storage/utils/decomposedfs/upload/processing.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,6 @@ func CreateNodeForUpload(upload *Upload, initAttrs map[string]string) (*node.Nod
initAttrs[prefixes.StatusPrefix] = node.ProcessingStatus + upload.Info.ID

// update node metadata with new blobid etc
appctx.GetLogger(upload.Ctx).Error().Str("nodeid", n.ID).Str("parentid", n.ParentID).Msg("Setting parent id")
err = n.SetXattrs(initAttrs, false)
if err != nil {
return nil, errors.Wrap(err, "Decomposedfs: could not write metadata")
Expand Down Expand Up @@ -336,7 +335,7 @@ func initNewNode(upload *Upload, n *node.Node, fsize uint64) (*lockedfile.File,

if _, ok := upload.lu.MetadataBackend().(metadata.IniBackend); ok {
// for the ini backend we also need to touch the actual node file here.
// it stores the mtime of thge resource, which must not change when we update the ini file
// it stores the mtime of the resource, which must not change when we update the ini file
h, err := os.OpenFile(n.InternalPath(), os.O_CREATE, 0600)
if err != nil {
return f, err
Expand Down

0 comments on commit 144d26e

Please sign in to comment.