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 0000000000..9be2dd2bc8 --- /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 154a396687..c03dc9f169 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 766d6013cd..849c78ce8e 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 dcdb079594..f641c8b608 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) }