Skip to content

Commit

Permalink
hellofs
Browse files Browse the repository at this point in the history
Signed-off-by: Jörn Friedrich Dreyer <[email protected]>
  • Loading branch information
butonic committed Nov 11, 2024
1 parent 372b288 commit ed7c580
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
16 changes: 10 additions & 6 deletions pkg/storage/fs/hello/hello.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
}
5 changes: 3 additions & 2 deletions pkg/storage/fs/hello/unimplemented.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit ed7c580

Please sign in to comment.