bump reva and deps

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
This commit is contained in:
Jörn Friedrich Dreyer
2025-02-28 17:40:07 +01:00
parent 63c4f0b1b4
commit a901ab860a
132 changed files with 3558 additions and 1479 deletions
@@ -46,6 +46,25 @@ type Trashbin struct {
log *zerolog.Logger
}
// trashNode is a helper struct to make trash items available for manipulation in the metadata backend
type trashNode struct {
spaceID string
id string
path string
}
func (tn *trashNode) GetSpaceID() string {
return tn.spaceID
}
func (tn *trashNode) GetID() string {
return tn.id
}
func (tn *trashNode) InternalPath() string {
return tn.path
}
const (
trashHeader = `[Trash Info]`
timeFormat = "2006-01-02T15:04:05"
@@ -254,7 +273,7 @@ func (tb *Trashbin) RestoreRecycleItem(ctx context.Context, ref *provider.Refere
return fmt.Errorf("trashbin: parent id not found for %s", restorePath)
}
trashNode := node.NewBaseNode(spaceID, id, tb.lu)
trashNode := &trashNode{spaceID: spaceID, id: id, path: trashPath}
err = tb.lu.MetadataBackend().Set(ctx, trashNode, prefixes.ParentidAttr, []byte(parentID))
if err != nil {
return err
@@ -701,7 +701,7 @@ func (t *Tree) WarmupIDCache(root string, assimilate, onlyDirty bool) error {
sizes := make(map[string]int64)
err := filepath.Walk(root, func(path string, info os.FileInfo, err error) error {
// skip lock and upload files
if isInternal(path) || isLockFile(path) {
if t.isInternal(path) || isLockFile(path) {
return nil
}
if isTrash(path) || t.isUpload(path) {
+10 -4
View File
@@ -325,6 +325,12 @@ func (t *Tree) Move(ctx context.Context, oldNode *node.Node, newNode *node.Node)
if newNode.ID == "" {
newNode.ID = oldNode.ID
}
// invalidate old tree
err = t.lookup.IDCache.DeleteByPath(ctx, filepath.Join(oldNode.ParentPath(), oldNode.Name))
if err != nil {
return err
}
if err := t.lookup.CacheID(ctx, newNode.SpaceID, newNode.ID, filepath.Join(newNode.ParentPath(), newNode.Name)); err != nil {
t.log.Error().Err(err).Str("spaceID", newNode.SpaceID).Str("id", newNode.ID).Str("path", filepath.Join(newNode.ParentPath(), newNode.Name)).Msg("could not cache id")
}
@@ -408,7 +414,7 @@ func (t *Tree) ListFolder(ctx context.Context, n *node.Node) ([]*node.Node, erro
g.Go(func() error {
defer close(work)
for _, name := range names {
if isInternal(name) || isLockFile(name) || isTrash(name) {
if t.isInternal(name) || isLockFile(name) || isTrash(name) {
continue
}
@@ -649,15 +655,15 @@ func (t *Tree) createDirNode(ctx context.Context, n *node.Node) (err error) {
var nodeIDRegep = regexp.MustCompile(`.*/nodes/([^.]*).*`)
func (t *Tree) isIgnored(path string) bool {
return isLockFile(path) || isTrash(path) || t.isUpload(path) || isInternal(path)
return isLockFile(path) || isTrash(path) || t.isUpload(path) || t.isInternal(path)
}
func (t *Tree) isUpload(path string) bool {
return strings.HasPrefix(path, t.options.UploadDirectory)
}
func isInternal(path string) bool {
return strings.Contains(path, lookup.RevisionsDir)
func (t *Tree) isInternal(path string) bool {
return path == t.options.Root || strings.HasPrefix(path, filepath.Join(t.options.Root, "indexes")) || strings.Contains(path, lookup.RevisionsDir)
}
func isLockFile(path string) bool {
@@ -475,6 +475,5 @@ func (tb *DecomposedfsTrashbin) EmptyRecycle(ctx context.Context, ref *provider.
}
func (tb *DecomposedfsTrashbin) getRecycleRoot(spaceID string) string {
rootNode := node.NewBaseNode(spaceID, spaceID, tb.fs.lu)
return filepath.Join(rootNode.InternalPath(), "trash")
return filepath.Join(tb.fs.o.Root, "spaces", lookup.Pathify(spaceID, 1, 2), "trash")
}
@@ -33,8 +33,6 @@ import (
"github.com/opencloud-eu/reva/v2/pkg/storage/pkg/decomposedfs/metadata/prefixes"
"github.com/opencloud-eu/reva/v2/pkg/storage/pkg/decomposedfs/node"
"github.com/opencloud-eu/reva/v2/pkg/storage/pkg/decomposedfs/options"
"github.com/pkg/errors"
"github.com/rogpeppe/go-internal/lockedfile"
"github.com/rs/zerolog"
"github.com/shamaton/msgpack/v2"
)
@@ -283,28 +281,18 @@ func (p AsyncPropagator) propagate(ctx context.Context, pn PropagationNode, reca
attrs := node.Attributes{}
var f *lockedfile.File
// lock parent before reading treesize or tree time
_, subspan = tracer.Start(ctx, "lockedfile.OpenFile")
lockFilepath := p.lookup.MetadataBackend().LockfilePath(pn)
f, err = lockedfile.OpenFile(lockFilepath, os.O_RDWR|os.O_CREATE, 0600)
unlock, err := p.lookup.MetadataBackend().Lock(pn)
subspan.End()
if err != nil {
log.Error().Err(err).
Str("lock filepath", lockFilepath).
Str("lock filepath", p.lookup.MetadataBackend().LockfilePath(pn)).
Msg("Propagation failed. Could not open metadata for node with lock.")
cleanup()
return
}
// always log error if closing node fails
defer func() {
// ignore already closed error
cerr := f.Close()
if err == nil && cerr != nil && !errors.Is(cerr, os.ErrClosed) {
err = cerr // only overwrite err with en error from close if the former was nil
}
}()
defer func() { _ = unlock() }()
_, subspan = tracer.Start(ctx, "node.ReadNode")
n, err := node.ReadNode(ctx, p.lookup, pn.GetSpaceID(), pn.GetID(), false, nil, false)
@@ -410,11 +398,8 @@ func (p AsyncPropagator) propagate(ctx context.Context, pn PropagationNode, reca
// Release node lock early, ignore already closed error
_, subspan = tracer.Start(ctx, "f.Close")
cerr := f.Close()
_ = unlock()
subspan.End()
if cerr != nil && !errors.Is(cerr, os.ErrClosed) {
log.Error().Err(cerr).Msg("Failed to close node and release lock")
}
log.Info().Msg("Propagation done. cleaning up")
cleanup()
@@ -20,8 +20,6 @@ package propagator
import (
"context"
"errors"
"os"
"strconv"
"time"
@@ -29,7 +27,6 @@ import (
"github.com/opencloud-eu/reva/v2/pkg/storage/pkg/decomposedfs/metadata"
"github.com/opencloud-eu/reva/v2/pkg/storage/pkg/decomposedfs/metadata/prefixes"
"github.com/opencloud-eu/reva/v2/pkg/storage/pkg/decomposedfs/node"
"github.com/rogpeppe/go-internal/lockedfile"
"github.com/rs/zerolog"
)
@@ -94,28 +91,19 @@ func (p SyncPropagator) propagateItem(ctx context.Context, n *node.Node, sTime t
attrs := node.Attributes{}
var f *lockedfile.File
// lock parent before reading treesize or tree time
_, subspan := tracer.Start(ctx, "lockedfile.OpenFile")
parentNode := node.NewBaseNode(n.SpaceID, n.ParentID, p.lookup)
parentFilename := p.lookup.MetadataBackend().LockfilePath(parentNode)
f, err := lockedfile.OpenFile(parentFilename, os.O_RDWR|os.O_CREATE, 0600)
unlock, err := p.lookup.MetadataBackend().Lock(parentNode)
subspan.End()
if err != nil {
log.Error().Err(err).
Str("parent filename", parentFilename).
Str("parent filename", parentNode.InternalPath()).
Msg("Propagation failed. Could not open metadata for parent with lock.")
return nil, true, err
}
// always log error if closing node fails
defer func() {
// ignore already closed error
cerr := f.Close()
if err == nil && cerr != nil && !errors.Is(cerr, os.ErrClosed) {
err = cerr // only overwrite err with en error from close if the former was nil
}
}()
defer func() { _ = unlock() }()
if n, err = n.Parent(ctx); err != nil {
log.Error().Err(err).