From 726af50e1692c328db2bb0737e81323d0e7976d5 Mon Sep 17 00:00:00 2001 From: Christian Richter Date: Fri, 4 Jul 2025 12:02:38 +0200 Subject: [PATCH] replace reva by fork Signed-off-by: Christian Richter --- go.sum | 4 +-- .../v2/pkg/storage/fs/owncloudsql/spaces.go | 5 ++++ .../pkg/storage/fs/posix/trashbin/trashbin.go | 23 +++++++++++++++++ .../pkg/storage/pkg/decomposedfs/recycle.go | 25 +++++++++++++++++++ .../v2/pkg/storage/pkg/decomposedfs/spaces.go | 8 ++++++ .../pkg/decomposedfs/trashbin/trashbin.go | 1 + .../pkg/storage/utils/decomposedfs/spaces.go | 1 + vendor/modules.txt | 3 ++- 8 files changed, 67 insertions(+), 3 deletions(-) diff --git a/go.sum b/go.sum index 1e7f268877..dc7f67ccf0 100644 --- a/go.sum +++ b/go.sum @@ -281,6 +281,8 @@ github.com/dlclark/regexp2 v1.4.0 h1:F1rxgk7p4uKjwIQxBs9oAXe5CqrXlCduYEJvrF4u93E github.com/dlclark/regexp2 v1.4.0/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc= github.com/dnaeon/go-vcr v1.0.1/go.mod h1:aBB1+wY4s93YsC3HHjMBMrwTj2R9FHDzUr9KyGc8n1E= github.com/dnsimple/dnsimple-go v0.63.0/go.mod h1:O5TJ0/U6r7AfT8niYNlmohpLbCSG+c71tQlGr9SeGrg= +github.com/dragonchaser/reva/v2 v2.0.0-20250704073728-ba915c60abf9 h1:v5HDeqlYHRTeu6eI/C91ddKQfuGFbolAPu3hGHHI9ag= +github.com/dragonchaser/reva/v2 v2.0.0-20250704073728-ba915c60abf9/go.mod h1:hSIUWU8JUaX+y0cVjbh6VaW6Mh0uJ/azFPx5cSVhQfc= github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY= github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto= github.com/dutchcoders/go-clamd v0.0.0-20170520113014-b970184f4d9e h1:rcHHSQqzCgvlwP0I/fQ8rQMn/MpHE5gWSLdtpxtP6KQ= @@ -868,8 +870,6 @@ github.com/opencloud-eu/go-micro-plugins/v4/store/nats-js-kv v0.0.0-202505121527 github.com/opencloud-eu/go-micro-plugins/v4/store/nats-js-kv v0.0.0-20250512152754-23325793059a/go.mod h1:pjcozWijkNPbEtX5SIQaxEW/h8VAVZYTLx+70bmB3LY= github.com/opencloud-eu/libre-graph-api-go v1.0.8-0.20250703062332-6dc201fd7bf1 h1:DNJ5mJdEKguSXSTeSBRG5yBZO8FnmWibAc6MlXbRxfc= github.com/opencloud-eu/libre-graph-api-go v1.0.8-0.20250703062332-6dc201fd7bf1/go.mod h1:pzatilMEHZFT3qV7C/X3MqOa3NlRQuYhlRhZTL+hN6Q= -github.com/opencloud-eu/reva/v2 v2.34.0 h1:9oiMWj3wAaooddgq2hskD6e+JBbdqzQNVublPMkhKDs= -github.com/opencloud-eu/reva/v2 v2.34.0/go.mod h1:hfXmgujx6teOLoh5dbDINaAgHYwXZZr9qYczxU/h+do= github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= github.com/opentracing/opentracing-go v1.2.0 h1:uEJPy/1a5RIPAJ0Ov+OIO8OxWu77jEv+1B0VhjKrZUs= github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYrxe9dPLANfrWvHYVTgc= diff --git a/vendor/github.com/opencloud-eu/reva/v2/pkg/storage/fs/owncloudsql/spaces.go b/vendor/github.com/opencloud-eu/reva/v2/pkg/storage/fs/owncloudsql/spaces.go index 9e2248a22f..0aaeddf39f 100644 --- a/vendor/github.com/opencloud-eu/reva/v2/pkg/storage/fs/owncloudsql/spaces.go +++ b/vendor/github.com/opencloud-eu/reva/v2/pkg/storage/fs/owncloudsql/spaces.go @@ -85,6 +85,11 @@ func (fs *owncloudsqlfs) ListStorageSpaces(ctx context.Context, filter []*provid } spaces = append(spaces, space) } + + for _, space := range spaces { + space.HasTrashedItems = false // owncloudsql does not support checking for trashed items + } + return spaces, nil } diff --git a/vendor/github.com/opencloud-eu/reva/v2/pkg/storage/fs/posix/trashbin/trashbin.go b/vendor/github.com/opencloud-eu/reva/v2/pkg/storage/fs/posix/trashbin/trashbin.go index 3b39a2a431..79edd177b5 100644 --- a/vendor/github.com/opencloud-eu/reva/v2/pkg/storage/fs/posix/trashbin/trashbin.go +++ b/vendor/github.com/opencloud-eu/reva/v2/pkg/storage/fs/posix/trashbin/trashbin.go @@ -397,3 +397,26 @@ func (tb *Trashbin) EmptyRecycle(ctx context.Context, spaceID string) error { } return os.RemoveAll(filepath.Clean(filepath.Join(trashRoot, "info"))) } + +func (tb *Trashbin) IsEmpty(ctx context.Context, spaceID string) bool { + _, span := tracer.Start(ctx, "HasTrashedItems") + defer span.End() + trashRoot := filepath.Join(tb.lu.InternalPath(spaceID, spaceID), ".Trash", "info") + trash, err := os.Open(filepath.Clean(trashRoot)) + if err != nil { + // there is no trash for this space, so no trashed items + return true + } + dirItems, err := trash.ReadDir(1) + if err != nil { + // if we cannot read the trash, we assume there are no trashed items + tb.log.Error().Err(err).Str("spaceID", spaceID).Msg("trashbin: error reading trash directory") + return true + } + if len(dirItems) > 0 { + // if we can read the trash and there are items, we assume there are trashed items + return false + } + // if we cannot read the trash, we assume there are no trashed items + return true +} diff --git a/vendor/github.com/opencloud-eu/reva/v2/pkg/storage/pkg/decomposedfs/recycle.go b/vendor/github.com/opencloud-eu/reva/v2/pkg/storage/pkg/decomposedfs/recycle.go index dc7d888fb6..0815a403dd 100644 --- a/vendor/github.com/opencloud-eu/reva/v2/pkg/storage/pkg/decomposedfs/recycle.go +++ b/vendor/github.com/opencloud-eu/reva/v2/pkg/storage/pkg/decomposedfs/recycle.go @@ -448,3 +448,28 @@ func (tb *DecomposedfsTrashbin) EmptyRecycle(ctx context.Context, spaceID string func (tb *DecomposedfsTrashbin) getRecycleRoot(spaceID string) string { return filepath.Join(tb.fs.o.Root, "spaces", lookup.Pathify(spaceID, 1, 2), "trash") } + +func (fs *DecomposedfsTrashbin) IsEmpty(ctx context.Context, spaceID string) bool { + log := appctx.GetLogger(ctx) + _, span := tracer.Start(ctx, "HasTrashedItems") + defer span.End() + + trashRoot := fs.getRecycleRoot(spaceID) + trash, err := os.Open(filepath.Clean(trashRoot)) + if err != nil { + // there is no trash for this space, so no trashed items + return true + } + dirItems, err := trash.ReadDir(1) + if err != nil { + // if we cannot read the trash, we assume there are no trashed items + log.Error().Err(err).Str("trashRoot", trashRoot).Str("spaceID", spaceID).Msg("trashbin: error reading trash directory") + return true + } + if len(dirItems) > 0 { + // if we can read the trash and there are items, we assume there are trashed items + return false + } + // if we cannot read the trash, we assume there are no trashed items + return true +} diff --git a/vendor/github.com/opencloud-eu/reva/v2/pkg/storage/pkg/decomposedfs/spaces.go b/vendor/github.com/opencloud-eu/reva/v2/pkg/storage/pkg/decomposedfs/spaces.go index a0086096c2..4dfd7136ec 100644 --- a/vendor/github.com/opencloud-eu/reva/v2/pkg/storage/pkg/decomposedfs/spaces.go +++ b/vendor/github.com/opencloud-eu/reva/v2/pkg/storage/pkg/decomposedfs/spaces.go @@ -493,6 +493,14 @@ func (fs *Decomposedfs) ListStorageSpaces(ctx context.Context, filter []*provide }() for r := range results { + r.HasTrashedItems = true + resourceID, err := storagespace.ParseID(r.GetId().GetOpaqueId()) + if err != nil { + appctx.GetLogger(ctx).Error().Err(err).Str("id", r.Id.GetOpaqueId()).Msg("could not parse space id") + r.HasTrashedItems = false + continue + } + r.HasTrashedItems = !fs.trashbin.IsEmpty(ctx, resourceID.GetSpaceId()) spaces = append(spaces, r) } diff --git a/vendor/github.com/opencloud-eu/reva/v2/pkg/storage/pkg/decomposedfs/trashbin/trashbin.go b/vendor/github.com/opencloud-eu/reva/v2/pkg/storage/pkg/decomposedfs/trashbin/trashbin.go index deb09d6d78..bd5d834de5 100644 --- a/vendor/github.com/opencloud-eu/reva/v2/pkg/storage/pkg/decomposedfs/trashbin/trashbin.go +++ b/vendor/github.com/opencloud-eu/reva/v2/pkg/storage/pkg/decomposedfs/trashbin/trashbin.go @@ -33,4 +33,5 @@ type Trashbin interface { RestoreRecycleItem(ctx context.Context, spaceID, key, relativePath string, restoreRef *provider.Reference) (*node.Node, error) PurgeRecycleItem(ctx context.Context, spaceID, key, relativePath string) error EmptyRecycle(ctx context.Context, spaceID string) error + IsEmpty(ctx context.Context, spaceID string) bool } diff --git a/vendor/github.com/opencloud-eu/reva/v2/pkg/storage/utils/decomposedfs/spaces.go b/vendor/github.com/opencloud-eu/reva/v2/pkg/storage/utils/decomposedfs/spaces.go index 05047858ba..2d0619616e 100644 --- a/vendor/github.com/opencloud-eu/reva/v2/pkg/storage/utils/decomposedfs/spaces.go +++ b/vendor/github.com/opencloud-eu/reva/v2/pkg/storage/utils/decomposedfs/spaces.go @@ -493,6 +493,7 @@ func (fs *Decomposedfs) ListStorageSpaces(ctx context.Context, filter []*provide }() for r := range results { + r.HasTrashedItems = false // FIXME: implement me spaces = append(spaces, r) } diff --git a/vendor/modules.txt b/vendor/modules.txt index ba49fd9991..aa8430dd42 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1210,7 +1210,7 @@ github.com/open-policy-agent/opa/v1/version # github.com/opencloud-eu/libre-graph-api-go v1.0.8-0.20250703062332-6dc201fd7bf1 ## explicit; go 1.18 github.com/opencloud-eu/libre-graph-api-go -# github.com/opencloud-eu/reva/v2 v2.34.0 +# github.com/opencloud-eu/reva/v2 v2.34.0 => github.com/dragonchaser/reva/v2 v2.0.0-20250704073728-ba915c60abf9 ## explicit; go 1.24.1 github.com/opencloud-eu/reva/v2/cmd/revad/internal/grace github.com/opencloud-eu/reva/v2/cmd/revad/runtime @@ -2478,3 +2478,4 @@ stash.kopano.io/kgol/rndm # github.com/unrolled/secure => github.com/DeepDiver1975/secure v0.0.0-20240611112133-abc838fb797c # go-micro.dev/v4 => github.com/butonic/go-micro/v4 v4.11.1-0.20241115112658-b5d4de5ed9b3 # github.com/go-micro/plugins/v4/store/nats-js-kv => github.com/opencloud-eu/go-micro-plugins/v4/store/nats-js-kv v0.0.0-20250512152754-23325793059a +# github.com/opencloud-eu/reva/v2 => github.com/dragonchaser/reva/v2 v2.0.0-20250704073728-ba915c60abf9