From 69a8aee5e96bf03a9fe9b197c31ef87ae6dfda3e Mon Sep 17 00:00:00 2001 From: Firas Frikha Date: Fri, 31 Jul 2026 11:13:55 +0200 Subject: [PATCH] chore: bump reva for coordinator upload fixes --- go.mod | 2 +- go.sum | 4 +- .../v2/pkg/storage/fs/nextcloud/nextcloud.go | 53 ++++++++++++++++--- .../fs/nextcloud/nextcloud_server_mock.go | 28 ++++++++-- .../utils/decomposedfs/decomposedfs.go | 7 +++ vendor/modules.txt | 2 +- 6 files changed, 80 insertions(+), 16 deletions(-) diff --git a/go.mod b/go.mod index fa2fc4af3cf..7a8399606b4 100644 --- a/go.mod +++ b/go.mod @@ -66,7 +66,7 @@ require ( github.com/open-policy-agent/opa v1.18.2 github.com/orcaman/concurrent-map v1.0.0 github.com/owncloud/libre-graph-api-go v1.0.5-0.20260216101009-eeac018af245 - github.com/owncloud/reva/v2 v2.0.0-20260731073733-d1451f3cf5c9 + github.com/owncloud/reva/v2 v2.0.0-20260731090840-11c62d397bce github.com/pkg/errors v0.9.1 github.com/pkg/xattr v0.4.12 github.com/prometheus/client_golang v1.24.1 diff --git a/go.sum b/go.sum index e69d6795564..4a15040af92 100644 --- a/go.sum +++ b/go.sum @@ -738,8 +738,8 @@ github.com/orcaman/concurrent-map v1.0.0 h1:I/2A2XPCb4IuQWcQhBhSwGfiuybl/J0ev9HD github.com/orcaman/concurrent-map v1.0.0/go.mod h1:Lu3tH6HLW3feq74c2GC+jIMS/K2CFcDWnWD9XkenwhI= github.com/owncloud/libre-graph-api-go v1.0.5-0.20260216101009-eeac018af245 h1:JRidLTAKhnvyLMRtVtSF4lhBa0NSAOs6fof+d6JnKII= github.com/owncloud/libre-graph-api-go v1.0.5-0.20260216101009-eeac018af245/go.mod h1:z61VMGAJRtR1nbgXWiNoCkxUXP1B3Je9rMuJbnGd+Og= -github.com/owncloud/reva/v2 v2.0.0-20260731073733-d1451f3cf5c9 h1:BO3yS83VvoW2jR01gtMYtoFyCiKNKUEnwiBgxCzhcIc= -github.com/owncloud/reva/v2 v2.0.0-20260731073733-d1451f3cf5c9/go.mod h1:hDxeY6kMe9RM+BAkHR13auD3AJSgnm4xZRs3XE9ckKQ= +github.com/owncloud/reva/v2 v2.0.0-20260731090840-11c62d397bce h1:IIMnpka5d+4YTGOSoVL7sfuB6QV04YJm5FByGkZHmQY= +github.com/owncloud/reva/v2 v2.0.0-20260731090840-11c62d397bce/go.mod h1:hDxeY6kMe9RM+BAkHR13auD3AJSgnm4xZRs3XE9ckKQ= github.com/oxtoacart/bpool v0.0.0-20190530202638-03653db5a59c h1:rp5dCmg/yLR3mgFuSOe4oEnDDmGLROTvMragMUXpTQw= github.com/oxtoacart/bpool v0.0.0-20190530202638-03653db5a59c/go.mod h1:X07ZCGwUbLaax7L0S3Tw4hpejzu63ZrrQiUe6W0hcy0= github.com/pablodz/inotifywaitgo v0.0.12 h1:DVJJTFMDlSAdO46yisPF2vzozs/r+4k6ih8MVghq78M= diff --git a/vendor/github.com/owncloud/reva/v2/pkg/storage/fs/nextcloud/nextcloud.go b/vendor/github.com/owncloud/reva/v2/pkg/storage/fs/nextcloud/nextcloud.go index 94eca439711..c736972986d 100644 --- a/vendor/github.com/owncloud/reva/v2/pkg/storage/fs/nextcloud/nextcloud.go +++ b/vendor/github.com/owncloud/reva/v2/pkg/storage/fs/nextcloud/nextcloud.go @@ -21,7 +21,6 @@ package nextcloud import ( "context" "encoding/json" - "fmt" "io" "net/http" "net/url" @@ -274,7 +273,33 @@ func (nc *StorageDriver) CreateDir(ctx context.Context, ref *provider.Reference) // TouchFile as defined in the storage.FS interface func (nc *StorageDriver) TouchFile(ctx context.Context, ref *provider.Reference, markprocessing bool, mtime string) (*storage.TouchFileResult, error) { - return nil, fmt.Errorf("unimplemented: TouchFile") + type paramsObj struct { + Ref *provider.Reference `json:"ref"` + MarkProcessing bool `json:"markprocessing"` + MTime string `json:"mtime"` + } + bodyStr, err := json.Marshal(¶msObj{Ref: ref, MarkProcessing: markprocessing, MTime: mtime}) + if err != nil { + return nil, err + } + log := appctx.GetLogger(ctx) + log.Info().Msgf("TouchFile %s", bodyStr) + + if _, _, err := nc.do(ctx, Action{"TouchFile", string(bodyStr)}); err != nil { + return nil, err + } + + // The upload coordinator needs the id of the node that was just created, and + // the touch call itself answers with an empty body, so read it back. + md, err := nc.GetMD(ctx, ref, []string{}, []string{}) + if err != nil { + return nil, err + } + return &storage.TouchFileResult{ + ResourceID: md.GetId(), + SpaceID: md.GetId().GetSpaceId(), + SpaceOwner: md.GetOwner(), + }, nil } // Delete as defined in the storage.FS interface @@ -409,14 +434,26 @@ func (nc *StorageDriver) InitiateUpload(ctx context.Context, ref *provider.Refer return respMap, err } -// MarkProcessing as defined in the storage.FS interface -func (nc *StorageDriver) MarkProcessing(ctx context.Context, ref *provider.Reference, processing bool, sessionID string) error { - return errtypes.NotSupported("nextcloud: mark processing not supported") +// MarkProcessing as defined in the storage.FS interface. +// +// The flag advertises an upload that has been announced but not yet committed, so +// that a stat of the file can say so. Nextcloud owns its own metadata and has +// nowhere to record it, and it does not postprocess uploads, so there is no window +// to report: this is a no-op rather than an error, which would fail the upload. +func (nc *StorageDriver) MarkProcessing(_ context.Context, _ *provider.Reference, _ bool, _ string) error { + return nil } -// CommitUpload as defined in the storage.FS interface -func (nc *StorageDriver) CommitUpload(_ context.Context, _ *provider.Reference, _ string, _ storage.UploadSource) error { - return errtypes.NotSupported("nextcloud: commit upload not supported") +// CommitUpload as defined in the storage.FS interface. +// +// The caller owns source.Body and closes it, so this must not. +func (nc *StorageDriver) CommitUpload(ctx context.Context, ref *provider.Reference, _ string, source storage.UploadSource) error { + if source.Body == nil { + return errtypes.BadRequest("nextcloud: source body is nil") + } + // The remote records the scan verdict itself if it scans at all, so + // source.ScanResult/ScanDate have nowhere to go here. + return nc.doUpload(ctx, ref.GetPath(), source.Body) } func (nc *StorageDriver) PrepareUpload(_ context.Context, _ *provider.Reference, _ string, info storage.UploadInfo) (*storage.PrepareUploadResult, error) { diff --git a/vendor/github.com/owncloud/reva/v2/pkg/storage/fs/nextcloud/nextcloud_server_mock.go b/vendor/github.com/owncloud/reva/v2/pkg/storage/fs/nextcloud/nextcloud_server_mock.go index b42ec12a6bf..f951390129b 100644 --- a/vendor/github.com/owncloud/reva/v2/pkg/storage/fs/nextcloud/nextcloud_server_mock.go +++ b/vendor/github.com/owncloud/reva/v2/pkg/storage/fs/nextcloud/nextcloud_server_mock.go @@ -25,6 +25,7 @@ import ( "net" "net/http" "net/http/httptest" + "regexp" "strings" ) @@ -52,6 +53,11 @@ const serverStateMetadata = "METADATA" var serverState = serverStateEmpty +// TouchFile carries the wall-clock mtime the upload was initiated with, so the +// request body differs on every run. Responses are keyed on the exact body, so +// the value is folded to a placeholder before lookup. +var mtimeRe = regexp.MustCompile(`"mtime":"[^"]*"`) + var responses = map[string]Response{ `POST /apps/sciencemesh/~f7fbf8c8-139b-4376-b307-cf0a8c2d0d9c/api/storage/AddGrant {"ref":{"path":"/subdir"},"g":{"grantee":{"type":1,"Id":{"UserId":{"opaque_id":"4c510ada-c86b-4815-8820-42cdf82c3d51"}}},"permissions":{"delete":true,"initiate_file_download":true,"move":true,"stat":true}}} EMPTY`: {200, ``, serverStateGrantAdded}, @@ -111,7 +117,20 @@ var responses = map[string]Response{ `POST /apps/sciencemesh/~f7fbf8c8-139b-4376-b307-cf0a8c2d0d9c/api/storage/GetPathByID {"storage_id":"00000000-0000-0000-0000-000000000000","opaque_id":"fileid-/some/path"} EMPTY`: {200, "/subdir", serverStateEmpty}, - `POST /apps/sciencemesh/~f7fbf8c8-139b-4376-b307-cf0a8c2d0d9c/api/storage/GetMD {"ref":{"path":"/file"},"mdKeys":null}`: {404, ``, serverStateEmpty}, + `POST /apps/sciencemesh/~f7fbf8c8-139b-4376-b307-cf0a8c2d0d9c/api/storage/GetMD {"ref":{"path":"/file"},"mdKeys":null}`: {404, ``, serverStateEmpty}, + // Initiating an upload now runs through the upload coordinator, which stats the + // target, checks the quota and stats the parent before it reaches the driver. + // The driver used to be called straight away, so none of these had an entry. + // They keep whichever state they matched: this mock selects responses by server + // state, and clearing it would strand the requests that follow. + `POST /apps/sciencemesh/~f7fbf8c8-139b-4376-b307-cf0a8c2d0d9c/api/storage/GetMD {"ref":{"path":"/file"},"mdKeys":[]} EMPTY`: {404, ``, serverStateEmpty}, + `POST /apps/sciencemesh/~f7fbf8c8-139b-4376-b307-cf0a8c2d0d9c/api/storage/GetQuota EMPTY`: {200, `{"totalBytes":456,"usedBytes":123}`, serverStateEmpty}, + `POST /apps/sciencemesh/~f7fbf8c8-139b-4376-b307-cf0a8c2d0d9c/api/storage/GetMD {"ref":{"path":"/"},"mdKeys":[]} EMPTY`: {200, `{"opaque":{},"type":2,"id":{"opaque_id":"fileid-/"},"checksum":{},"etag":"deadbeef","mime_type":"httpd/unix-directory","mtime":{"seconds":1234567890},"path":"/","permission_set":{"initiate_file_upload":true,"stat":true},"size":12345,"canonical_metadata":{},"arbitrary_metadata":{"metadata":{}}}`, serverStateEmpty}, + // A zero-length upload has no bytes to append, so it finishes inside + // InitiateUpload: the coordinator creates the node and stats it back for the id + // the touch minted. + `POST /apps/sciencemesh/~f7fbf8c8-139b-4376-b307-cf0a8c2d0d9c/api/storage/TouchFile {"ref":{"resource_id":{"opaque_id":"fileid-/"},"path":"file"},"markprocessing":false,"mtime":"MTIME"} EMPTY`: {200, ``, serverStateEmpty}, + `POST /apps/sciencemesh/~f7fbf8c8-139b-4376-b307-cf0a8c2d0d9c/api/storage/GetMD {"ref":{"resource_id":{"opaque_id":"fileid-/"},"path":"file"},"mdKeys":[]} EMPTY`: {200, `{"opaque":{},"type":1,"id":{"opaque_id":"fileid-/file"},"checksum":{},"etag":"deadbeef","mime_type":"text/plain","mtime":{"seconds":1234567890},"path":"/file","permission_set":{"initiate_file_upload":true,"stat":true},"size":0,"canonical_metadata":{},"arbitrary_metadata":{"metadata":{}}}`, serverStateEmpty}, `POST /apps/sciencemesh/~f7fbf8c8-139b-4376-b307-cf0a8c2d0d9c/api/storage/InitiateUpload {"ref":{"path":"/file"},"uploadLength":0,"metadata":{"providerID":""}}`: {200, `{"simple": "yes","tus": "yes"}`, serverStateEmpty}, `POST /apps/sciencemesh/~f7fbf8c8-139b-4376-b307-cf0a8c2d0d9c/api/storage/InitiateUpload {"ref":{"resource_id":{"storage_id":"f7fbf8c8-139b-4376-b307-cf0a8c2d0d9c"},"path":"/versionedFile"},"uploadLength":1,"metadata":{}}`: {200, `{"simple": "yes","tus": "yes"}`, serverStateEmpty}, `POST /apps/sciencemesh/~f7fbf8c8-139b-4376-b307-cf0a8c2d0d9c/api/storage/InitiateUpload {"ref":{"resource_id":{"storage_id":"f7fbf8c8-139b-4376-b307-cf0a8c2d0d9c"},"path":"/versionedFile"},"uploadLength":2,"metadata":{}}`: {200, `{"simple": "yes","tus": "yes"}`, serverStateEmpty}, @@ -194,15 +213,16 @@ func GetNextcloudServerMock(called *[]string) http.Handler { if err != nil { panic("Error reading response into buffer") } - var key = fmt.Sprintf("%s %s %s", r.Method, r.URL, buf.String()) + body := mtimeRe.ReplaceAllString(buf.String(), `"mtime":"MTIME"`) + var key = fmt.Sprintf("%s %s %s", r.Method, r.URL, body) *called = append(*called, key) response := responses[key] if (response == Response{}) { - key = fmt.Sprintf("%s %s %s %s", r.Method, r.URL, buf.String(), serverState) + key = fmt.Sprintf("%s %s %s %s", r.Method, r.URL, body, serverState) response = responses[key] } if (response == Response{}) { - fmt.Printf("%s %s %s %s\n", r.Method, r.URL, buf.String(), serverState) + fmt.Printf("%s %s %s %s\n", r.Method, r.URL, body, serverState) response = Response{500, fmt.Sprintf("response not defined! %s", key), serverStateEmpty} } serverState = responses[key].newServerState diff --git a/vendor/github.com/owncloud/reva/v2/pkg/storage/utils/decomposedfs/decomposedfs.go b/vendor/github.com/owncloud/reva/v2/pkg/storage/utils/decomposedfs/decomposedfs.go index fdea63af37d..0311a7d189f 100644 --- a/vendor/github.com/owncloud/reva/v2/pkg/storage/utils/decomposedfs/decomposedfs.go +++ b/vendor/github.com/owncloud/reva/v2/pkg/storage/utils/decomposedfs/decomposedfs.go @@ -231,6 +231,13 @@ func New(o *options.Options, aspects aspects.Aspects, log *zerolog.Logger) (stor aspects.UserMapper = &usermapper.NullMapper{} } + // Callers may disable versioning through either the options or the aspects: the + // posix driver builds its own aspects and only sets it there. Fold it into the + // options so code reading o.DisableVersioning sees it too. + if aspects.DisableVersioning { + o.DisableVersioning = true + } + fs := &Decomposedfs{ tp: aspects.Tree, lu: aspects.Lookup, diff --git a/vendor/modules.txt b/vendor/modules.txt index 06edeb8269e..5ab4af79672 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1316,7 +1316,7 @@ github.com/orcaman/concurrent-map # github.com/owncloud/libre-graph-api-go v1.0.5-0.20260216101009-eeac018af245 ## explicit; go 1.18 github.com/owncloud/libre-graph-api-go -# github.com/owncloud/reva/v2 v2.0.0-20260731073733-d1451f3cf5c9 +# github.com/owncloud/reva/v2 v2.0.0-20260731090840-11c62d397bce ## explicit; go 1.26 github.com/owncloud/reva/v2/cmd/revad/internal/grace github.com/owncloud/reva/v2/cmd/revad/runtime