Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix quota calculation #4902

Merged
merged 1 commit into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions changelog/unreleased/fix-quota-calculation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Bugfix: Fix quota calculation

Quota would show "exceeded" when remaining quota was 0 because total was 0.

https://github.com/cs3org/reva/pull/4902
10 changes: 8 additions & 2 deletions pkg/storage/utils/decomposedfs/decomposedfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"context"
"fmt"
"io"
"math"
"net/url"
"path"
"path/filepath"
Expand Down Expand Up @@ -603,7 +604,9 @@ func (fs *Decomposedfs) GetQuota(ctx context.Context, ref *provider.Reference) (

func (fs *Decomposedfs) calculateTotalUsedRemaining(quotaStr string, inUse uint64) (uint64, uint64, uint64, error) {
var err error
var total, remaining uint64
var total uint64

remaining := uint64(math.MaxUint64)
switch quotaStr {
case node.QuotaUncalculated, node.QuotaUnknown:
// best we can do is return current total
Expand All @@ -616,8 +619,11 @@ func (fs *Decomposedfs) calculateTotalUsedRemaining(quotaStr string, inUse uint6
return 0, 0, 0, err
}

if total > inUse {
switch {
case total > inUse:
remaining = total - inUse
case total <= inUse:
remaining = 0
}

}
Expand Down
Loading