diff --git a/code/go/0chain.net/blobbercore/allocation/newdirchange.go b/code/go/0chain.net/blobbercore/allocation/newdirchange.go index 6d5778fd0..3db4ba3a4 100644 --- a/code/go/0chain.net/blobbercore/allocation/newdirchange.go +++ b/code/go/0chain.net/blobbercore/allocation/newdirchange.go @@ -11,6 +11,8 @@ import ( "github.com/0chain/blobber/code/go/0chain.net/blobbercore/util" "github.com/0chain/blobber/code/go/0chain.net/core/common" "github.com/0chain/blobber/code/go/0chain.net/core/encryption" + "github.com/0chain/blobber/code/go/0chain.net/core/logging" + "go.uber.org/zap" "gorm.io/gorm" ) @@ -33,6 +35,19 @@ func (nf *NewDir) ApplyChange(ctx context.Context, if parentRef == nil || parentRef.ID == 0 { _, err = reference.Mkdir(ctx, nf.AllocationID, nf.Path, allocationVersion, ts, collector) } else { + collector.LockTransaction() + defer collector.UnlockTransaction() + dirLookupHash := reference.GetReferenceLookup(nf.AllocationID, nf.Path) + dRef, err := reference.GetLimitedRefFieldsByLookupHash(ctx, nf.AllocationID, dirLookupHash, []string{"id"}) + if err != nil && err != gorm.ErrRecordNotFound { + logging.Logger.Error("ApplyChange:Newdir", zap.Error(err)) + return err + } + err = nil + // already exists + if dRef != nil && dRef.ID != 0 { + return nil + } parentIDRef := &parentRef.ID newRef := reference.NewDirectoryRef() newRef.AllocationID = nf.AllocationID @@ -43,7 +58,7 @@ func (nf *NewDir) ApplyChange(ctx context.Context, newRef.Name = filepath.Base(nf.Path) newRef.PathLevel = len(strings.Split(strings.TrimRight(nf.Path, "/"), "/")) newRef.ParentID = parentIDRef - newRef.LookupHash = reference.GetReferenceLookup(nf.AllocationID, nf.Path) + newRef.LookupHash = dirLookupHash newRef.CreatedAt = ts newRef.UpdatedAt = ts newRef.FileMetaHash = encryption.FastHash(newRef.GetFileMetaHashData()) diff --git a/code/go/0chain.net/blobbercore/config/config.go b/code/go/0chain.net/blobbercore/config/config.go index 7403ecb52..73c9e3bdf 100644 --- a/code/go/0chain.net/blobbercore/config/config.go +++ b/code/go/0chain.net/blobbercore/config/config.go @@ -32,7 +32,7 @@ func SetupDefaultConfig() { viper.SetDefault("rate_limiters.block_limit_request", 500) viper.SetDefault("rate_limiters.block_limit_monthly", 31250000) viper.SetDefault("rate_limiters.upload_limit_monthly", 31250000) - viper.SetDefault("rate_limiters.commit_limit_monthly", 30000) + viper.SetDefault("rate_limiters.commit_limit_monthly", 1000000000) viper.SetDefault("rate_limiters.commit_limit_daily", 1600) viper.SetDefault("rate_limiters.commit_zero_limit_daily", 400) viper.SetDefault("rate_limiters.max_connection_changes", 100) diff --git a/code/go/0chain.net/blobbercore/reference/ref.go b/code/go/0chain.net/blobbercore/reference/ref.go index 1068815c6..53df6c7da 100644 --- a/code/go/0chain.net/blobbercore/reference/ref.go +++ b/code/go/0chain.net/blobbercore/reference/ref.go @@ -256,6 +256,7 @@ func Mkdir(ctx context.Context, allocationID, destpath string, allocationVersion newRef.AllocationVersion = allocationVersion err = db.Create(newRef).Error if err != nil { + logging.Logger.Error("mkdir: failed to create directory", zap.Error(err), zap.String("path", fields[i])) return nil, err } collector.AddToCache(newRef) diff --git a/config/0chain_blobber.yaml b/config/0chain_blobber.yaml index 100a3788f..758bab823 100755 --- a/config/0chain_blobber.yaml +++ b/config/0chain_blobber.yaml @@ -76,7 +76,7 @@ rate_limiters: # Max upload limit in a month for a client. Default is 2000GB(the value needs to be in blocks which is data/64KB) upload_limit_monthly: 31250000 # Max commit limit in a month for a client. Default is 30000 - commit_limit_monthly: 30000 + commit_limit_monthly: 1000000000 # Max commit limit in a day for a client. Default is 1600 commit_limit_daily: 1600 # Max commit limit with size zero or less in a day for a client. Default is 400