Skip to content

Commit

Permalink
Revert "fix(decomposedfs): available space calculation"
Browse files Browse the repository at this point in the history
This reverts commit b5c3c67.
  • Loading branch information
kobergj committed Oct 23, 2024
1 parent ec051f7 commit 48f4fb4
Show file tree
Hide file tree
Showing 14 changed files with 2 additions and 96 deletions.
5 changes: 0 additions & 5 deletions pkg/storage/fs/ocis/blobstore/blobstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,6 @@ func (bs *Blobstore) Delete(node *node.Node) error {
return nil
}

// GetAvailableSize returns the available size in the blobstore in bytes
func (bs *Blobstore) GetAvailableSize(n *node.Node) (uint64, error) {
return node.GetAvailableSize(n.InternalPath())
}

// List lists all blobs in the Blobstore
func (bs *Blobstore) List() ([]*node.Node, error) {
dirs, err := filepath.Glob(filepath.Join(bs.root, "spaces", "*", "*", "blobs", "*", "*", "*", "*", "*"))
Expand Down
5 changes: 0 additions & 5 deletions pkg/storage/fs/posix/blobstore/blobstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,3 @@ func (bs *Blobstore) Download(node *node.Node) (io.ReadCloser, error) {
func (bs *Blobstore) Delete(node *node.Node) error {
return nil
}

// GetAvailableSize returns the available size in the blobstore in bytes
func (bs *Blobstore) GetAvailableSize(n *node.Node) (uint64, error) {
return node.GetAvailableSize(n.InternalPath())
}
1 change: 0 additions & 1 deletion pkg/storage/fs/posix/posix.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ func New(m map[string]interface{}, stream events.Stream) (storage.FS, error) {
aspects := aspects.Aspects{
Lookup: lu,
Tree: tp,
Blobstore: bs,
Permissions: p,
EventStream: stream,
UserMapper: um,
Expand Down
2 changes: 0 additions & 2 deletions pkg/storage/fs/posix/testhelpers/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,6 @@ func NewTestEnv(config map[string]interface{}) (*TestEnv, error) {
)

bs := &treemocks.Blobstore{}
bs.On("GetAvailableSize", mock.Anything).Return(uint64(1000000000), nil)
tree, err := tree.New(lu, bs, um, &trashbin.Trashbin{}, o, nil, store.Create())
if err != nil {
return nil, err
Expand All @@ -190,7 +189,6 @@ func NewTestEnv(config map[string]interface{}) (*TestEnv, error) {
aspects := aspects.Aspects{
Lookup: lu,
Tree: tree,
Blobstore: bs,
Permissions: permissions.NewPermissions(pmock, permissionsSelector),
Trashbin: tb,
}
Expand Down
7 changes: 0 additions & 7 deletions pkg/storage/fs/s3ng/blobstore/blobstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import (

"github.com/cs3org/reva/v2/pkg/storage/utils/decomposedfs/lookup"
"github.com/cs3org/reva/v2/pkg/storage/utils/decomposedfs/node"
"github.com/cs3org/reva/v2/pkg/storage/utils/decomposedfs/tree"
"github.com/minio/minio-go/v7"
"github.com/minio/minio-go/v7/pkg/credentials"
"github.com/pkg/errors"
Expand Down Expand Up @@ -129,12 +128,6 @@ func (bs *Blobstore) Delete(node *node.Node) error {
return nil
}

// GetAvailableSize returns the available size in the blobstore in bytes
func (bs *Blobstore) GetAvailableSize(n *node.Node) (uint64, error) {
// S3 doen't have a concept of available size
return 0, tree.ErrSizeUnlimited
}

// List lists all blobs in the Blobstore
func (bs *Blobstore) List() ([]*node.Node, error) {
ch := bs.client.ListObjects(context.Background(), bs.bucket, minio.ListObjectsOptions{Recursive: true})
Expand Down
2 changes: 0 additions & 2 deletions pkg/storage/utils/decomposedfs/aspects/aspects.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,13 @@ import (
"github.com/cs3org/reva/v2/pkg/storage/utils/decomposedfs/node"
"github.com/cs3org/reva/v2/pkg/storage/utils/decomposedfs/permissions"
"github.com/cs3org/reva/v2/pkg/storage/utils/decomposedfs/trashbin"
"github.com/cs3org/reva/v2/pkg/storage/utils/decomposedfs/tree"
"github.com/cs3org/reva/v2/pkg/storage/utils/decomposedfs/usermapper"
)

// Aspects holds dependencies for handling aspects of the decomposedfs
type Aspects struct {
Lookup node.PathLookup
Tree node.Tree
Blobstore tree.Blobstore
Trashbin trashbin.Trashbin
Permissions permissions.Permissions
EventStream events.Stream
Expand Down
3 changes: 0 additions & 3 deletions pkg/storage/utils/decomposedfs/decomposedfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ type SessionStore interface {
type Decomposedfs struct {
lu node.PathLookup
tp node.Tree
bs tree.Blobstore
trashbin trashbin.Trashbin
o *options.Options
p permissions.Permissions
Expand Down Expand Up @@ -163,7 +162,6 @@ func NewDefault(m map[string]interface{}, bs tree.Blobstore, es events.Stream) (
aspects := aspects.Aspects{
Lookup: lu,
Tree: tp,
Blobstore: bs,
Permissions: permissions.NewPermissions(node.NewPermissions(lu), permissionsSelector),
EventStream: es,
DisableVersioning: o.DisableVersioning,
Expand Down Expand Up @@ -225,7 +223,6 @@ func New(o *options.Options, aspects aspects.Aspects) (storage.FS, error) {

fs := &Decomposedfs{
tp: aspects.Tree,
bs: aspects.Blobstore,
lu: aspects.Lookup,
trashbin: aspects.Trashbin,
o: o,
Expand Down
1 change: 0 additions & 1 deletion pkg/storage/utils/decomposedfs/decomposedfs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ var _ = Describe("Decomposed", func() {
Describe("NewDefault", func() {
It("works", func() {
bs := &treemocks.Blobstore{}
bs.On("GetAvailableSize", mock.Anything).Return(uint64(1000000000), nil)
_, err := decomposedfs.NewDefault(map[string]interface{}{
"root": env.Root,
"permissionssvc": "any",
Expand Down
4 changes: 1 addition & 3 deletions pkg/storage/utils/decomposedfs/spaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -1035,9 +1035,7 @@ func (fs *Decomposedfs) StorageSpaceFromNode(ctx context.Context, n *node.Node,
}
space.Opaque = utils.AppendPlainToOpaque(space.Opaque, "quota.total", strconv.FormatUint(total, 10))
space.Opaque = utils.AppendPlainToOpaque(space.Opaque, "quota.used", strconv.FormatUint(used, 10))
if remaining != math.MaxUint64 {
space.Opaque = utils.AppendPlainToOpaque(space.Opaque, "quota.remaining", strconv.FormatUint(remaining, 10))
}
space.Opaque = utils.AppendPlainToOpaque(space.Opaque, "quota.remaining", strconv.FormatUint(remaining, 10))

return space, nil
}
Expand Down
2 changes: 0 additions & 2 deletions pkg/storage/utils/decomposedfs/testhelpers/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,6 @@ func NewTestEnv(config map[string]interface{}) (*TestEnv, error) {
aspects := aspects.Aspects{
Lookup: lu,
Tree: tree,
Blobstore: bs,
Permissions: permissions.NewPermissions(pmock, permissionsSelector),
Trashbin: &decomposedfs.DecomposedfsTrashbin{},
}
Expand Down Expand Up @@ -291,7 +290,6 @@ func (t *TestEnv) CreateTestStorageSpace(typ string, quota *providerv1beta1.Quot
if typ == "personal" {
owner = t.Owner
}
t.Blobstore.On("GetAvailableSize", mock.Anything).Return(uint64(1000000000), nil)
space, err := t.Fs.CreateStorageSpace(t.Ctx, &providerv1beta1.CreateStorageSpaceRequest{
Owner: owner,
Type: typ,
Expand Down
56 changes: 0 additions & 56 deletions pkg/storage/utils/decomposedfs/tree/mocks/Blobstore.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 1 addition & 5 deletions pkg/storage/utils/decomposedfs/tree/tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,7 @@ import (
"golang.org/x/sync/errgroup"
)

var (
tracer trace.Tracer
ErrSizeUnlimited = errors.New("blobstore size unlimited")
)
var tracer trace.Tracer

func init() {
tracer = otel.Tracer("github.com/cs3org/reva/pkg/storage/utils/decomposedfs/tree")
Expand All @@ -62,7 +59,6 @@ type Blobstore interface {
Upload(node *node.Node, source string) error
Download(node *node.Node) (io.ReadCloser, error)
Delete(node *node.Node) error
GetAvailableSize(node *node.Node) (uint64, error)
}

// Tree manages a hierarchical tree
Expand Down
2 changes: 0 additions & 2 deletions pkg/storage/utils/decomposedfs/upload_async_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,6 @@ var _ = Describe("Async file uploads", Ordered, func() {
},
)
bs = &treemocks.Blobstore{}
bs.On("GetAvailableSize", mock.Anything).Return(uint64(1000000000), nil)

// create space uses CheckPermission endpoint
cs3permissionsclient.On("CheckPermission", mock.Anything, mock.Anything, mock.Anything).Return(&cs3permissions.CheckPermissionResponse{
Expand All @@ -177,7 +176,6 @@ var _ = Describe("Async file uploads", Ordered, func() {
aspects := aspects.Aspects{
Lookup: lu,
Tree: tree,
Blobstore: bs,
Permissions: permissions.NewPermissions(pmock, permissionsSelector),
EventStream: stream.Chan{pub, con},
Trashbin: &DecomposedfsTrashbin{},
Expand Down
2 changes: 0 additions & 2 deletions pkg/storage/utils/decomposedfs/upload_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,13 +136,11 @@ var _ = Describe("File uploads", func() {
AddGrant: true,
}, nil).Times(1)
var err error
bs.On("GetAvailableSize", mock.Anything).Return(uint64(1000000000), nil).Times(1)
tree := tree.New(lu, bs, o, store.Create())

aspects := aspects.Aspects{
Lookup: lu,
Tree: tree,
Blobstore: bs,
Permissions: permissions.NewPermissions(pmock, permissionsSelector),
Trashbin: &decomposedfs.DecomposedfsTrashbin{},
}
Expand Down

0 comments on commit 48f4fb4

Please sign in to comment.