Skip to content

Commit

Permalink
Merge pull request #4902 from kobergj/FixQuotaCalculation
Browse files Browse the repository at this point in the history
Fix quota calculation
  • Loading branch information
kobergj authored Oct 28, 2024
2 parents dd9fa42 + 1c11eed commit 4188019
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
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

0 comments on commit 4188019

Please sign in to comment.