Skip to content

port upload driver contract: PrepareUpload, RollbackUpload, scan results - #906

Merged
butonic merged 11 commits into
opencloud-eu:workpackagesfrom
butonic:port-664-669-688-690-694
Oct 28, 2026
Merged

butonic merged 11 commits into
opencloud-eu:workpackagesfrom
butonic:port-664-669-688-690-694

Conversation

@butonic

@butonic butonic commented Oct 23, 2026 •

Copy link
Copy Markdown
Member

Ported and adapted with Claude Code (claude-opus-5-5). Each port is two commits: the upstream change with its original author, then our adaptation for the pkg decomposedfs fork and posix. Reviewing commit by commit is easiest.

Completes the storage driver side of the new upload pipeline: a driver can now prepare, commit and roll back an upload on its own. Nothing calls these methods yet; that comes with the upload coordinator. The legacy pkg/storage/utils/decomposedfs copy gets the methods unchanged; our own behaviour is only in the pkg/storage/pkg/decomposedfs fork.

PrepareUpload

Called after all bytes are received and before postprocessing. It re-checks the preconditions (If-Match, If-None-Match, If-Unmodified-Since) and the quota, snapshots the previous version, writes the new node metadata (blob id = session id, size, checksums, mtime) and propagates the size diff.

  • The quota is checked for new files too, not only for overwrites.
  • The pkg/storage/pkg/decomposedfs fork snapshots through the tree's CreateRevision, like the legacy upload path does: posix keeps a copy of the current content as a revision, decomposedfs only copies the metadata.
  • On failure it removes that revision without retaking the node lock and restores the old mtime in the same batch as the other attributes.

CommitUpload

  • Commits against the real, locked node. If a newer upload took over the node in the meantime, the bytes go into the revision whose blob id is the session id.
  • UploadSource.Path lets a caller hand over a staged file in addition to the body: the pkg fork uses it, so posix moves the file into place instead of copying the body. Posix uploads from a reader are staged in .oc-tmp.
  • UploadSource.ScanResult / ScanDate carry the virus scan result. It is stored on the node, or on the revision when the upload was taken over.

RollbackUpload

  • For an overwrite, it restores the latest revision and reverts the size propagation. Without a revision (versioning disabled), the pkg fork returns PreconditionFailed and leaves the node alone, because the previous metadata can't be restored. The legacy pkg/storage/utils/decomposedfs copy keeps its original behaviour and purges the node.
  • For a file the upload created, it purges the node.

Also included

  • ChunkHandler.Assemble assembles chunked uploads without going through the legacy upload path.
  • The DisableVersioning aspect is marked redundant: every driver copies the option into it, and only the legacy upload session store reads it.

Tests

New specs for PrepareUpload, CommitUpload and RollbackUpload in both decomposedfs copies, plus posix specs (posix_prepare_upload_test.go) for snapshots, staged files, takeover and rollback. go test ./pkg/storage/... and golangci-lint pass. The upstream commits for PrepareUpload and RollbackUpload don't build on their own (the pkg fork gets the new methods in the commit after); every adaptation commit does.

@butonic
butonic force-pushed the port-664-669-688-690-694 branch from e269ea9 to 747b180 Compare October 23, 2026 09:28
LarsJurgensen and others added 5 commits October 23, 2026 12:34
The pkg decomposedfs fork gets PrepareUpload in the next commit.
The pkg decomposedfs fork snapshots the previous version through the
tree's CreateRevision, like the legacy upload path does, so posix keeps
a copy of the current content as a revision while decomposedfs only
copies the metadata. On failure it removes that revision without
retaking the node lock and restores the old mtime in the same batch as
the other attributes.

Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Jörn Friedrich Dreyer <[email protected]>
CommitUpload wrote the staged bytes through a bare node without a space
root, which the posix blobstore rejects, and always onto the live node.
On posix the content lives in the node itself, so:

- commit against the real, locked node
- if a newer upload took over the node, write into the revision that
  upload created for this session; without one (versioning disabled)
  discard the bytes, nothing references them
- add UploadSource.Path so a staged file can be moved into place
  instead of copied from a reader
- stage posix reader uploads in the space's .oc-tmp dir, which the
  watcher ignores, and don't re-stage a file that already is there

Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Jörn Friedrich Dreyer <[email protected]>
Hunks that conflict with our revert code (RevertUpload) keep our side; the next
commit adapts RollbackUpload to it.
Both decomposedfs copies get Node.RevertLatestRevision, which restores
the latest revision onto the node and removes it, without purging the
node or unmarking processing. RollbackUpload uses it. Without a revision
(versioning disabled) it returns PreconditionFailed and leaves the node
alone instead of purging it, as the previous metadata can't be restored.

Adds RollbackUpload to the pkg fork, with specs for both copies and
posix.

Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Jörn Friedrich Dreyer <[email protected]>
@butonic
butonic force-pushed the port-664-669-688-690-694 branch 2 times, most recently from d47af19 to 97e8298 Compare October 23, 2026 10:45
@butonic butonic self-assigned this Oct 23, 2026
f-firas and others added 5 commits October 23, 2026 13:38
Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Jörn Friedrich Dreyer <[email protected]>
RollbackUpload keeps our PreconditionFailed when there is no revision
to restore. The pkg decomposedfs fork gets the fixes in the next commit.
- PrepareUpload checks the quota for new files too
- CommitUpload stores the scan result on the node that holds the
  content: the node, or the revision when a newer upload took over
- RollbackUpload purges a node the upload created

Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Jörn Friedrich Dreyer <[email protected]>
Every driver copies options.DisableVersioning into the aspect, and only
the legacy upload session store reads it; PrepareUpload reads the
option. It can go when the upload coordinator replaces that store.

Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Jörn Friedrich Dreyer <[email protected]>
@butonic
butonic force-pushed the port-664-669-688-690-694 branch from 97e8298 to d575223 Compare October 23, 2026 11:40
The legacy decomposedfs copy stays a snapshot of the original driver,
including its known flaws; our own upload behaviour lives in the pkg
fork. So this undoes what the earlier commits added there:

- CommitUpload takes a body only; a staged file path is for the pkg fork
- RollbackUpload purges an existing node when there is no revision to
  restore, like upstream, instead of returning PreconditionFailed
- Node.RevertCurrentRevision provides upstream's API on top of our
  RevertUpload; DeleteRevision is back as it was
- the rollback specs are upstream's

Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Jörn Friedrich Dreyer <[email protected]>

@dragonchaser dragonchaser left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lgtm

@butonic
butonic changed the base branch from main to workpackages October 28, 2026 09:16
@butonic
butonic marked this pull request as ready for review October 28, 2026 09:16
@butonic

butonic commented Oct 28, 2026

Copy link
Copy Markdown
Member Author

we are going to collect some prs in the workpackages branch until the bugfixing phase for the production release is over

@butonic
butonic merged commit e541dac into opencloud-eu:workpackages Oct 28, 2026
19 checks passed
butonic added a commit to butonic/reva that referenced this pull request Oct 28, 2026
workpackages merged opencloud-eu#906 as e541dac, which left this branch with two
merge bases (the 2.52.1 release and the opencloud-eu#906 head). git resolves that
cleanly, but GitHub reports the PR as conflicting. Merging back collapses
the history to a single base and brings in the guest share type for
propfind (opencloud-eu#918).

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.

4 participants