From 66845777246ce56aa63839ee37dca6b101a55248 Mon Sep 17 00:00:00 2001 From: Michael Barz Date: Fri, 25 Oct 2024 14:31:48 +0200 Subject: [PATCH] chore: update reva to 2.26.2 Signed-off-by: jkoberg --- changelog/unreleased/bump-reva.md | 6 ++++ go.mod | 2 +- go.sum | 4 +-- .../storage/fs/ocis/blobstore/blobstore.go | 5 ---- .../storage/fs/posix/blobstore/blobstore.go | 5 ---- .../reva/v2/pkg/storage/fs/posix/posix.go | 1 - .../storage/fs/s3ng/blobstore/blobstore.go | 7 ----- .../utils/decomposedfs/aspects/aspects.go | 2 -- .../utils/decomposedfs/decomposedfs.go | 30 +++++++------------ .../pkg/storage/utils/decomposedfs/spaces.go | 14 ++------- .../storage/utils/decomposedfs/tree/tree.go | 6 +--- vendor/modules.txt | 4 +-- 12 files changed, 24 insertions(+), 62 deletions(-) create mode 100644 changelog/unreleased/bump-reva.md diff --git a/changelog/unreleased/bump-reva.md b/changelog/unreleased/bump-reva.md new file mode 100644 index 00000000000..3f473cd7d0d --- /dev/null +++ b/changelog/unreleased/bump-reva.md @@ -0,0 +1,6 @@ +Enhancement: Bump reva to 2.26.2 + +* Enhancement [cs3org/reva#4897](https://github.com/cs3org/reva/pull/4897): Fix remaining quota calculation +* Bugfix [cs3org/reva#4902](https://github.com/cs3org/reva/pull/4902): Fix quota calculation + +https://github.com/owncloud/ocis/pull/10419 diff --git a/go.mod b/go.mod index a66ecc475d9..5edabbcbd17 100644 --- a/go.mod +++ b/go.mod @@ -15,7 +15,7 @@ require ( github.com/cenkalti/backoff v2.2.1+incompatible github.com/coreos/go-oidc/v3 v3.11.0 github.com/cs3org/go-cs3apis v0.0.0-20240724121416-062c4e3046cb - github.com/cs3org/reva/v2 v2.26.0 + github.com/cs3org/reva/v2 v2.26.2 github.com/davidbyttow/govips/v2 v2.15.0 github.com/dhowden/tag v0.0.0-20240417053706-3d75831295e8 github.com/dutchcoders/go-clamd v0.0.0-20170520113014-b970184f4d9e diff --git a/go.sum b/go.sum index d1dd9aef7be..88180192b68 100644 --- a/go.sum +++ b/go.sum @@ -255,8 +255,8 @@ github.com/crewjam/saml v0.4.14 h1:g9FBNx62osKusnFzs3QTN5L9CVA/Egfgm+stJShzw/c= github.com/crewjam/saml v0.4.14/go.mod h1:UVSZCf18jJkk6GpWNVqcyQJMD5HsRugBPf4I1nl2mME= github.com/cs3org/go-cs3apis v0.0.0-20240724121416-062c4e3046cb h1:KmYZDReplv/yfwc1LNYpDcVhVujC3Pasv6WjXx1haSU= github.com/cs3org/go-cs3apis v0.0.0-20240724121416-062c4e3046cb/go.mod h1:yyP8PRo0EZou3nSH7H4qjlzQwaydPeIRNgX50npQHpE= -github.com/cs3org/reva/v2 v2.26.0 h1:FTM0L0eP9MOfnEgmU9R+fAjCstgk0dCDbDMm9xg2FA4= -github.com/cs3org/reva/v2 v2.26.0/go.mod h1:b+AwpMCeJo7pihdjr0ZBvs7gvgbVNCzFpCOIHqS2hiY= +github.com/cs3org/reva/v2 v2.26.2 h1:0J+Ph9iM6zlVex11vu2p94hRiqiCBgSTwWg03c5qDfg= +github.com/cs3org/reva/v2 v2.26.2/go.mod h1:b+AwpMCeJo7pihdjr0ZBvs7gvgbVNCzFpCOIHqS2hiY= github.com/cyberdelia/templates v0.0.0-20141128023046-ca7fffd4298c/go.mod h1:GyV+0YP4qX0UQ7r2MoYZ+AvYDp12OF5yg4q8rGnyNh4= github.com/cyphar/filepath-securejoin v0.2.4 h1:Ugdm7cg7i6ZK6x3xDF1oEu1nfkyfH53EtKeQYTC3kyg= github.com/cyphar/filepath-securejoin v0.2.4/go.mod h1:aPGpWjXOXUn2NCNjFvBE6aRxGGx79pTxQpKOJNYHHl4= diff --git a/vendor/github.com/cs3org/reva/v2/pkg/storage/fs/ocis/blobstore/blobstore.go b/vendor/github.com/cs3org/reva/v2/pkg/storage/fs/ocis/blobstore/blobstore.go index 83604b015a7..b4293fa645a 100644 --- a/vendor/github.com/cs3org/reva/v2/pkg/storage/fs/ocis/blobstore/blobstore.go +++ b/vendor/github.com/cs3org/reva/v2/pkg/storage/fs/ocis/blobstore/blobstore.go @@ -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", "*", "*", "*", "*", "*")) diff --git a/vendor/github.com/cs3org/reva/v2/pkg/storage/fs/posix/blobstore/blobstore.go b/vendor/github.com/cs3org/reva/v2/pkg/storage/fs/posix/blobstore/blobstore.go index 5e152ec1cae..cf01a9e138e 100644 --- a/vendor/github.com/cs3org/reva/v2/pkg/storage/fs/posix/blobstore/blobstore.go +++ b/vendor/github.com/cs3org/reva/v2/pkg/storage/fs/posix/blobstore/blobstore.go @@ -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()) -} diff --git a/vendor/github.com/cs3org/reva/v2/pkg/storage/fs/posix/posix.go b/vendor/github.com/cs3org/reva/v2/pkg/storage/fs/posix/posix.go index ef0e264ab7c..537689d4595 100644 --- a/vendor/github.com/cs3org/reva/v2/pkg/storage/fs/posix/posix.go +++ b/vendor/github.com/cs3org/reva/v2/pkg/storage/fs/posix/posix.go @@ -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, diff --git a/vendor/github.com/cs3org/reva/v2/pkg/storage/fs/s3ng/blobstore/blobstore.go b/vendor/github.com/cs3org/reva/v2/pkg/storage/fs/s3ng/blobstore/blobstore.go index 4751168a5a5..aaeecf65f8c 100644 --- a/vendor/github.com/cs3org/reva/v2/pkg/storage/fs/s3ng/blobstore/blobstore.go +++ b/vendor/github.com/cs3org/reva/v2/pkg/storage/fs/s3ng/blobstore/blobstore.go @@ -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" @@ -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}) diff --git a/vendor/github.com/cs3org/reva/v2/pkg/storage/utils/decomposedfs/aspects/aspects.go b/vendor/github.com/cs3org/reva/v2/pkg/storage/utils/decomposedfs/aspects/aspects.go index 18eb88eed4e..65a9e0d983f 100644 --- a/vendor/github.com/cs3org/reva/v2/pkg/storage/utils/decomposedfs/aspects/aspects.go +++ b/vendor/github.com/cs3org/reva/v2/pkg/storage/utils/decomposedfs/aspects/aspects.go @@ -23,7 +23,6 @@ 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" ) @@ -31,7 +30,6 @@ import ( type Aspects struct { Lookup node.PathLookup Tree node.Tree - Blobstore tree.Blobstore Trashbin trashbin.Trashbin Permissions permissions.Permissions EventStream events.Stream diff --git a/vendor/github.com/cs3org/reva/v2/pkg/storage/utils/decomposedfs/decomposedfs.go b/vendor/github.com/cs3org/reva/v2/pkg/storage/utils/decomposedfs/decomposedfs.go index f7b8a84d63e..22ccb4ba711 100644 --- a/vendor/github.com/cs3org/reva/v2/pkg/storage/utils/decomposedfs/decomposedfs.go +++ b/vendor/github.com/cs3org/reva/v2/pkg/storage/utils/decomposedfs/decomposedfs.go @@ -113,7 +113,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 @@ -164,7 +163,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, @@ -226,7 +224,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, @@ -602,20 +599,14 @@ func (fs *Decomposedfs) GetQuota(ctx context.Context, ref *provider.Reference) ( quotaStr = string(ri.Opaque.Map["quota"].Value) } - remaining, err = fs.bs.GetAvailableSize(n) - switch { - case errors.Is(err, tree.ErrSizeUnlimited): - remaining = math.MaxUint64 - case err != nil: - return 0, 0, 0, err - } - - return fs.calculateTotalUsedRemaining(quotaStr, ri.Size, remaining) + return fs.calculateTotalUsedRemaining(quotaStr, ri.Size) } -func (fs *Decomposedfs) calculateTotalUsedRemaining(quotaStr string, inUse, remaining uint64) (uint64, uint64, uint64, error) { +func (fs *Decomposedfs) calculateTotalUsedRemaining(quotaStr string, inUse uint64) (uint64, uint64, uint64, error) { var err error var total uint64 + + remaining := uint64(math.MaxUint64) switch quotaStr { case node.QuotaUncalculated, node.QuotaUnknown: // best we can do is return current total @@ -628,14 +619,13 @@ func (fs *Decomposedfs) calculateTotalUsedRemaining(quotaStr string, inUse, rema return 0, 0, 0, err } - if total <= remaining { - // Prevent overflowing - if inUse >= total { - remaining = 0 - } else { - remaining = total - inUse - } + switch { + case total > inUse: + remaining = total - inUse + case total <= inUse: + remaining = 0 } + } return total, inUse, remaining, nil } diff --git a/vendor/github.com/cs3org/reva/v2/pkg/storage/utils/decomposedfs/spaces.go b/vendor/github.com/cs3org/reva/v2/pkg/storage/utils/decomposedfs/spaces.go index c8f4268a33a..760ad96552c 100644 --- a/vendor/github.com/cs3org/reva/v2/pkg/storage/utils/decomposedfs/spaces.go +++ b/vendor/github.com/cs3org/reva/v2/pkg/storage/utils/decomposedfs/spaces.go @@ -46,7 +46,6 @@ import ( "github.com/cs3org/reva/v2/pkg/storage/utils/decomposedfs/metadata/prefixes" "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/tree" "github.com/cs3org/reva/v2/pkg/storage/utils/templates" "github.com/cs3org/reva/v2/pkg/storagespace" "github.com/cs3org/reva/v2/pkg/utils" @@ -1030,22 +1029,13 @@ func (fs *Decomposedfs) StorageSpaceFromNode(ctx context.Context, n *node.Node, quotaStr = quotaInOpaque } - remaining, err := fs.bs.GetAvailableSize(n) - switch { - case errors.Is(err, tree.ErrSizeUnlimited): - remaining = math.MaxUint64 - case err != nil: - return nil, err - } - total, used, remaining, err := fs.calculateTotalUsedRemaining(quotaStr, space.GetRootInfo().GetSize(), remaining) + total, used, remaining, err := fs.calculateTotalUsedRemaining(quotaStr, space.GetRootInfo().GetSize()) if err != nil { return nil, err } 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 } diff --git a/vendor/github.com/cs3org/reva/v2/pkg/storage/utils/decomposedfs/tree/tree.go b/vendor/github.com/cs3org/reva/v2/pkg/storage/utils/decomposedfs/tree/tree.go index 31ade9af4fd..e2530530472 100644 --- a/vendor/github.com/cs3org/reva/v2/pkg/storage/utils/decomposedfs/tree/tree.go +++ b/vendor/github.com/cs3org/reva/v2/pkg/storage/utils/decomposedfs/tree/tree.go @@ -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") @@ -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 diff --git a/vendor/modules.txt b/vendor/modules.txt index de97ec7af29..c6c73675cec 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -368,7 +368,7 @@ github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1 github.com/cs3org/go-cs3apis/cs3/storage/registry/v1beta1 github.com/cs3org/go-cs3apis/cs3/tx/v1beta1 github.com/cs3org/go-cs3apis/cs3/types/v1beta1 -# github.com/cs3org/reva/v2 v2.26.0 +# github.com/cs3org/reva/v2 v2.26.2 ## explicit; go 1.22.0 github.com/cs3org/reva/v2/cmd/revad/internal/grace github.com/cs3org/reva/v2/cmd/revad/runtime @@ -2406,7 +2406,7 @@ sigs.k8s.io/yaml/goyaml.v2 ## explicit; go 1.13 stash.kopano.io/kgol/rndm # github.com/studio-b12/gowebdav => github.com/aduffeck/gowebdav v0.0.0-20231215102054-212d4a4374f6 -# go-micro.dev/v4 => github.com/butonic/go-micro/v4 v4.11.1-0.20241028133844-ac2cdce96c71 # github.com/egirna/icap-client => github.com/fschade/icap-client v0.0.0-20240802074440-aade4a234387 # github.com/unrolled/secure => github.com/DeepDiver1975/secure v0.0.0-20240611112133-abc838fb797c # github.com/go-micro/plugins/v4/store/nats-js-kv => github.com/kobergj/plugins/v4/store/nats-js-kv v0.0.0-20240807130109-f62bb67e8c90 +# go-micro.dev/v4 => github.com/butonic/go-micro/v4 v4.11.1-0.20241028133844-ac2cdce96c71