Skip to content

Commit 22f0d75

Browse files
committed
fix allocationSize in file command
1 parent baa5ee1 commit 22f0d75

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

code/go/0chain.net/blobbercore/handler/file_command_update.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,15 +132,15 @@ func (cmd *UpdateFileCommand) ProcessContent(ctx context.Context, allocationObj
132132
result.FixedMerkleRoot = fileOutputData.FixedMerkleRoot
133133
result.Size = fileOutputData.Size
134134

135-
allocationSize := allocation.GetConnectionObjSize(connID)
136-
137135
cmd.fileChanger.AllocationID = allocationObj.ID
138136

139137
cmd.allocationChange = &allocation.AllocationChange{}
140138
cmd.allocationChange.ConnectionID = connID
141139
cmd.allocationChange.Size = cmd.fileChanger.Size - cmd.existingFileRef.Size
142140
cmd.allocationChange.Operation = sdkConst.FileOperationUpdate
143141

142+
allocationSize := allocation.GetConnectionObjSize(connID) + cmd.allocationChange.Size
143+
144144
if cmd.fileChanger.IsFinal {
145145
result.UpdateChange = true
146146
cmd.reloadChange()
@@ -170,7 +170,7 @@ func (cmd *UpdateFileCommand) ProcessContent(ctx context.Context, allocationObj
170170
}
171171
}
172172

173-
if allocationObj.BlobberSizeUsed+(allocationSize-cmd.existingFileRef.Size) > allocationObj.BlobberSize {
173+
if allocationObj.BlobberSizeUsed+allocationSize > allocationObj.BlobberSize {
174174
return result, common.NewError("max_allocation_size", "Max size reached for the allocation with this blobber")
175175
}
176176

code/go/0chain.net/blobbercore/handler/file_command_upload.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ func (cmd *UploadFileCommand) ProcessContent(ctx context.Context, allocationObj
147147
result.ValidationRoot = fileOutputData.ValidationRoot
148148
result.Size = fileOutputData.Size
149149

150-
allocationSize := allocation.GetConnectionObjSize(connectionID)
150+
allocationSize := allocation.GetConnectionObjSize(connectionID) + cmd.fileChanger.Size
151151
cmd.fileChanger.AllocationID = allocationObj.ID
152152

153153
cmd.allocationChange = &allocation.AllocationChange{}

0 commit comments

Comments
 (0)