Skip to content

Commit

Permalink
unlimited storage if config not defined
Browse files Browse the repository at this point in the history
  • Loading branch information
cheggaaa committed Jul 13, 2023
1 parent 7a32dc1 commit e37e376
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions filelimit/filelimit.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ package filelimit

import (
"context"
"fmt"
"github.com/anyproto/any-sync-coordinator/cafeapi"
"github.com/anyproto/any-sync-coordinator/db"
"github.com/anyproto/any-sync-coordinator/spacestatus"
"github.com/anyproto/any-sync/app"
"github.com/anyproto/any-sync/coordinator/coordinatorproto"
"github.com/anyproto/any-sync/util/crypto"
"math"
"time"
)

Expand Down Expand Up @@ -36,9 +36,6 @@ func (f *fileLimit) Init(a *app.App) (err error) {
f.cafeApi = a.MustComponent(cafeapi.CName).(cafeapi.CafeApi)
f.spaceStatus = a.MustComponent(spacestatus.CName).(spacestatus.SpaceStatus)
f.conf = a.MustComponent("config").(configGetter).GetFileLimit()
if f.conf.LimitDefault == 0 {
return fmt.Errorf("file limit should be presented in the config")
}
return
}

Expand All @@ -59,6 +56,11 @@ func (f *fileLimit) Get(ctx context.Context, identity []byte, spaceId string) (l
return 0, coordinatorproto.ErrSpaceIsDeleted
}

if f.conf.LimitDefault == 0 {
// if not defined - unlimited
return math.MaxUint64, nil
}

var shouldCheckCafe bool
limit, err = f.db.Get(ctx, spaceId)
if err != nil {
Expand Down

0 comments on commit e37e376

Please sign in to comment.