From ed7c58080d76c89f78bb2d52addca0ed8ce336da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Friedrich=20Dreyer?= Date: Mon, 11 Nov 2024 15:51:55 +0100 Subject: [PATCH] hellofs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jörn Friedrich Dreyer --- pkg/storage/fs/hello/hello.go | 16 ++++++++++------ pkg/storage/fs/hello/unimplemented.go | 5 +++-- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/pkg/storage/fs/hello/hello.go b/pkg/storage/fs/hello/hello.go index 0a9d72e2d0..f87062feb4 100644 --- a/pkg/storage/fs/hello/hello.go +++ b/pkg/storage/fs/hello/hello.go @@ -29,6 +29,7 @@ import ( "time" provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1" + "github.com/cs3org/reva/v2/pkg/errtypes" "github.com/cs3org/reva/v2/pkg/events" "github.com/cs3org/reva/v2/pkg/storage" @@ -222,20 +223,23 @@ func (fs *hellofs) ListFolder(ctx context.Context, ref *provider.Reference, mdKe } // Download returns a ReadCloser for the content of the referenced resource -func (fs *hellofs) Download(ctx context.Context, ref *provider.Reference) (io.ReadCloser, error) { +func (fs *hellofs) Download(ctx context.Context, ref *provider.Reference, openReaderFunc func(md *provider.ResourceInfo) bool) (*provider.ResourceInfo, io.ReadCloser, error) { info, err := fs.lookup(ctx, ref) if err != nil { - return nil, err + return nil, nil, err } - if info.Type != provider.ResourceType_RESOURCE_TYPE_FILE { - return nil, errtypes.InternalError("expected a file") + return nil, nil, errtypes.InternalError("expected a file") } if info.GetId().GetOpaqueId() != fileid { - return nil, errtypes.InternalError("unknown file") + return nil, nil, errtypes.InternalError("unknown file") + } + + if !openReaderFunc(info) { + return info, nil, nil } b := &bytes.Buffer{} b.WriteString(content) - return io.NopCloser(b), nil + return info, io.NopCloser(b), nil } diff --git a/pkg/storage/fs/hello/unimplemented.go b/pkg/storage/fs/hello/unimplemented.go index 3490b81083..24079d2906 100644 --- a/pkg/storage/fs/hello/unimplemented.go +++ b/pkg/storage/fs/hello/unimplemented.go @@ -24,6 +24,7 @@ import ( "net/url" provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1" + "github.com/cs3org/reva/v2/pkg/errtypes" "github.com/cs3org/reva/v2/pkg/storage" ) @@ -153,8 +154,8 @@ func (fs *hellofs) ListRevisions(ctx context.Context, ref *provider.Reference) ( } // DownloadRevision downloads a revision -func (fs *hellofs) DownloadRevision(ctx context.Context, ref *provider.Reference, revisionKey string) (io.ReadCloser, error) { - return nil, errtypes.NotSupported("unimplemented") +func (fs *hellofs) DownloadRevision(ctx context.Context, ref *provider.Reference, revisionKey string, openReaderFunc func(md *provider.ResourceInfo) bool) (*provider.ResourceInfo, io.ReadCloser, error) { + return nil, nil, errtypes.NotSupported("unimplemented") } // RestoreRevision restores a revision