replace reva by fork

Signed-off-by: Christian Richter <c.richter@opencloud.eu>
This commit is contained in:
Christian Richter
2025-07-04 12:05:02 +02:00
parent 818490592f
commit 726af50e16
8 changed files with 67 additions and 3 deletions
@@ -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
}
@@ -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
}
@@ -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
}
@@ -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)
}
@@ -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
}
@@ -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)
}
+2 -1
View File
@@ -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