Skip to content

feat(OCISDEV-944): migrate Delete to typed DeleteResult - #617

Merged
f-firas merged 2 commits into
mainfrom
OCISDEV-944
Jun 12, 2026
Merged

f-firas merged 2 commits into
mainfrom
OCISDEV-944

Conversation

@f-firas

@f-firas f-firas commented Jun 4, 2026

Copy link
Copy Markdown

Summary

The Delete flow previously relied on a couple of awkward patterns to ferry data from the storage driver up to the events interceptor — the deleted file's id was stuffed into DeleteResponse.Opaque["opaque_id"], and the space owner traveled through a context channel
(ContextSendSpaceOwnerID). Both worked, but they were stringly-typed and easy to lose track of. This PR replaces them with a typed return value.

storage.FS.Delete now returns a *storage.DeleteResult alongside the error. The struct carries the two pieces of information the events interceptor needs:

type DeleteResult struct {
    SpaceOwner *userpb.UserId
    ResourceId *provider.ResourceId
}

Drivers that have rich data (decomposedfs) populate the result; drivers that don't (s3, eosfs, localfs, ...) return an empty &DeleteResult{} and the conversion layer falls back to req.Ref when building the event. Either way, the published ItemTrashed payload stays
structurally identical to before.

To get the typed result from the driver to the events interceptor without changing the gRPC protobuf, the storageprovider writes it into a DeleteResultSlot registered in the context — a small mutable container the interceptor allocates before the handler runs and reads
back after. Same trick as the existing sendOwnerChan pattern, but typed and one-shot.

A few related cleanups come along for the ride:

  • The GetMD pre-flight in storageprovider.Delete is gone. Its only remaining purpose was the "is this file still processing?" check, which now lives inside decomposedfs.Delete (the only driver that has a notion of "processing"). The gRPC service stops paying for an
    extra round-trip on every delete across every backend.
  • The processing check returns errtypes.TooEarly, which is now wired through NewStatusFromErrType to map cleanly to CODE_TOO_EARLY on the wire — same response code as before, just produced from a typed error instead of an inline Status construction.
  • The ContextSendSpaceOwnerID call inside decomposedfs.Delete is removed; the owner is now part of the typed return.

Acceptance criteria

  • GetMD call in storageprovider.Delete() removed
  • DeleteResponse.Opaque["opaque_id"] smuggling removed
  • ContextSendSpaceOwnerID no longer called from the driver for Delete

Test plan

  • go build ./... and go vet ./... pass
  • Existing decomposedfs Delete tests still pass; a new test asserts that DeleteResult is populated
  • New eventsmiddleware/conversion_test.go covers the four scenarios ItemTrashed can encounter (typed result, empty result, nil result, driver supplies a full ResourceId)
  • Verified end-to-end against ocis: deleting a file produces an ItemTrashed event whose payload (SpaceOwner, Executant, ID.{storage_id, space_id, opaque_id}, Ref) matches the pre-PR baseline

@kw-security

kw-security commented Jun 4, 2026 •

Copy link
Copy Markdown

✅ Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
✅ Code Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@kobergj kobergj left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great 👍 Just minor remarks...

Comment thread pkg/storagespace/context.go Resolved
kobergj
kobergj previously approved these changes Jun 11, 2026
@f-firas
f-firas requested a review from kobergj June 12, 2026 12:41
@f-firas
f-firas merged commit a68875b into main Jun 12, 2026
14 checks passed
@f-firas
f-firas deleted the OCISDEV-944 branch June 12, 2026 12:57
dragonchaser pushed a commit to opencloud-eu/reva that referenced this pull request Nov 11, 2026
FS.Delete now returns a DeleteResult with the space owner and the id of
the deleted node. The storageprovider puts it into a context slot and
the events middleware builds ItemTrashed from it, so the event carries
the id of the trashed node even when the request referenced it by
parent id and relative path.

We keep our stat before deleting: it rejects deleting files that are
still processing and puts the node id into the response opaque. For
drivers that do not return a result ItemTrashed falls back to that
opaque id before using the id from the request.

backport of owncloud#617

Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Jörn Friedrich Dreyer <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants