From 5698bf2d433452f2547eac55e7be3dc05e829bf9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Friedrich=20Dreyer?= Date: Wed, 21 Aug 2024 11:01:05 +0200 Subject: [PATCH] use key to get specific trash item MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jörn Friedrich Dreyer --- changelog/unreleased/use-key-to-get-specific-trash-item.md | 5 +++++ services/activitylog/pkg/service/response.go | 1 + services/clientlog/pkg/service/service.go | 1 + services/storage-users/pkg/command/trash_bin.go | 2 +- 4 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 changelog/unreleased/use-key-to-get-specific-trash-item.md diff --git a/changelog/unreleased/use-key-to-get-specific-trash-item.md b/changelog/unreleased/use-key-to-get-specific-trash-item.md new file mode 100644 index 00000000000..9be2dd2bc81 --- /dev/null +++ b/changelog/unreleased/use-key-to-get-specific-trash-item.md @@ -0,0 +1,5 @@ +Bugfix: Use key to get specific trash item + +The activitylog and clientlog services now only fetch the specific trash item instead of getting all items in trash and filtering them on their side. This reduces the load on the storage users service because it no longer has to assemble a full trash listing. + +https://github.com/owncloud/ocis/pull/9879 diff --git a/services/activitylog/pkg/service/response.go b/services/activitylog/pkg/service/response.go index 154a3966878..c03dc9f169c 100644 --- a/services/activitylog/pkg/service/response.go +++ b/services/activitylog/pkg/service/response.go @@ -99,6 +99,7 @@ func WithTrashedResource(ref *provider.Reference, rid *provider.ResourceId) Acti resp, err := gwc.ListRecycle(ctx, &provider.ListRecycleRequest{ Ref: ref, + Key: rid.GetOpaqueId(), }) if err != nil { return err diff --git a/services/clientlog/pkg/service/service.go b/services/clientlog/pkg/service/service.go index 766d6013cd6..849c78ce8ec 100644 --- a/services/clientlog/pkg/service/service.go +++ b/services/clientlog/pkg/service/service.go @@ -221,6 +221,7 @@ func processShareEvent(ctx context.Context, ref *provider.Reference, gwc gateway func processItemTrashedEvent(ctx context.Context, ref *provider.Reference, gwc gateway.GatewayAPIClient, initiatorid string, itemID *provider.ResourceId) ([]string, FileEvent, error) { resp, err := gwc.ListRecycle(ctx, &provider.ListRecycleRequest{ Ref: ref, + Key: itemID.GetOpaqueId(), }) if err != nil { return nil, FileEvent{}, err diff --git a/services/storage-users/pkg/command/trash_bin.go b/services/storage-users/pkg/command/trash_bin.go index dcdb079594f..f641c8b6089 100644 --- a/services/storage-users/pkg/command/trash_bin.go +++ b/services/storage-users/pkg/command/trash_bin.go @@ -345,7 +345,7 @@ func restoreTrashBindItem(cfg *config.Config) *cli.Command { func listRecycle(ctx context.Context, client gateway.GatewayAPIClient, ref provider.Reference) (*provider.ListRecycleResponse, error) { _retrievingErrorMsg := "trash-bin items retrieving error" - res, err := client.ListRecycle(ctx, &provider.ListRecycleRequest{Ref: &ref, Key: "/"}) + res, err := client.ListRecycle(ctx, &provider.ListRecycleRequest{Ref: &ref, Key: ""}) if err != nil { return nil, fmt.Errorf("%s %w", _retrievingErrorMsg, err) }