Skip to content

Commit

Permalink
Merge pull request #1530 from 0chain/fix/rmv-sizecheck
Browse files Browse the repository at this point in the history
Remove alloc size check in upload
  • Loading branch information
dabasov committed Jun 15, 2024
2 parents 89b23cc + a610c39 commit b9a50cf
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 41 deletions.
13 changes: 0 additions & 13 deletions zboxcore/sdk/chunked_upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,24 +142,11 @@ func CreateChunkedUpload(
}

opCode := OpUpload
spaceLeft := allocationObj.Size
if allocationObj.Stats != nil {
spaceLeft -= allocationObj.Stats.UsedSize
}

if isUpdate {
f, err := allocationObj.GetFileMeta(fileMeta.RemotePath)
if err != nil {
return nil, err
}
spaceLeft += f.ActualFileSize
opCode = OpUpdate
}

if fileMeta.ActualSize > spaceLeft {
return nil, ErrNoEnoughSpaceLeftInAllocation
}

consensus := Consensus{
RWMutex: &sync.RWMutex{},
consensusThresh: allocationObj.consensusThreshold,
Expand Down
28 changes: 0 additions & 28 deletions zboxcore/sdk/upload_worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"io"
"strings"

thrown "github.com/0chain/errors"
"github.com/0chain/gosdk/constants"
"github.com/0chain/gosdk/core/sys"
"github.com/0chain/gosdk/zboxcore/allocationchange"
Expand Down Expand Up @@ -94,33 +93,6 @@ func (uo *UploadOperation) buildChange(_ []fileref.RefEntity, uid uuid.UUID) []a
}

func (uo *UploadOperation) Verify(allocationObj *Allocation) error {
if allocationObj == nil {
return thrown.Throw(constants.ErrInvalidParameter, "allocationObj")
}

if !uo.isUpdate && !allocationObj.CanUpload() || uo.isUpdate && !allocationObj.CanUpdate() {
return thrown.Throw(constants.ErrFileOptionNotPermitted, "file_option_not_permitted ")
}

err := ValidateRemoteFileName(uo.chunkedUpload.fileMeta.RemoteName)
if err != nil {
return err
}
spaceLeft := allocationObj.Size
if allocationObj.Stats != nil {
spaceLeft -= allocationObj.Stats.UsedSize
}

if uo.isUpdate {
f, err := allocationObj.GetFileMeta(uo.chunkedUpload.fileMeta.RemotePath)
if err != nil {
return err
}
spaceLeft += f.ActualFileSize
}
if uo.chunkedUpload.fileMeta.ActualSize > spaceLeft {
return ErrNoEnoughSpaceLeftInAllocation
}
return nil
}

Expand Down

0 comments on commit b9a50cf

Please sign in to comment.