Skip to content

Commit a89b435

Browse files
committed
update conn size in save change
1 parent 101c6c4 commit a89b435

File tree

3 files changed

+5
-11
lines changed

3 files changed

+5
-11
lines changed

code/go/0chain.net/blobbercore/allocation/connection.go

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ func UpdateConnectionObjSize(connectionID string, addSize int64) {
166166
connectionObj.UpdatedAt = time.Now()
167167
}
168168

169-
func SaveFileChange(connectionID, pathHash, fileName string, cmd FileCommand, isFinal bool, contentSize int64, offset, dataWritten int64) (bool, error) {
169+
func SaveFileChange(connectionID, pathHash, fileName string, cmd FileCommand, isFinal bool, contentSize, offset, dataWritten, addSize int64) (bool, error) {
170170
connectionObjMutex.RLock()
171171
connectionObj := connectionProcessor[connectionID]
172172
connectionObjMutex.RUnlock()
@@ -210,14 +210,8 @@ func SaveFileChange(connectionID, pathHash, fileName string, cmd FileCommand, is
210210
Offset: offset,
211211
DataBytes: dataWritten,
212212
}, contentSize)
213-
if change.existingRef != nil {
214-
logging.Logger.Info("updateConnSize: ", zap.Int64("contentSize", contentSize), zap.Int64("currentSize", change.existingRef.Size))
215-
contentSize -= change.existingRef.Size
216-
} else {
217-
logging.Logger.Info("updateConnSize: ", zap.Int64("contentSize", contentSize))
218-
}
219-
if contentSize != 0 {
220-
UpdateConnectionObjSize(connectionID, contentSize)
213+
if addSize != 0 {
214+
UpdateConnectionObjSize(connectionID, addSize)
221215
}
222216
} else {
223217
change.seqPQ.Push(seqpriorityqueue.UploadData{

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ func (cmd *UpdateFileCommand) ProcessContent(allocationObj *allocation.Allocatio
156156
}
157157
}
158158

159-
saveChange, err := allocation.SaveFileChange(connID, cmd.fileChanger.PathHash, cmd.fileChanger.Filename, cmd, cmd.fileChanger.IsFinal, cmd.fileChanger.Size, cmd.fileChanger.UploadOffset, fileOutputData.Size)
159+
saveChange, err := allocation.SaveFileChange(connID, cmd.fileChanger.PathHash, cmd.fileChanger.Filename, cmd, cmd.fileChanger.IsFinal, cmd.fileChanger.Size, cmd.fileChanger.UploadOffset, fileOutputData.Size, cmd.fileChanger.Size-cmd.existingFileRef.Size)
160160
if err != nil {
161161
return result, err
162162
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ func (cmd *UploadFileCommand) ProcessContent(allocationObj *allocation.Allocatio
174174
}
175175
}
176176

177-
saveChange, err := allocation.SaveFileChange(connectionID, cmd.fileChanger.PathHash, cmd.fileChanger.Filename, cmd, cmd.fileChanger.IsFinal, cmd.fileChanger.Size, cmd.fileChanger.UploadOffset, fileOutputData.Size)
177+
saveChange, err := allocation.SaveFileChange(connectionID, cmd.fileChanger.PathHash, cmd.fileChanger.Filename, cmd, cmd.fileChanger.IsFinal, cmd.fileChanger.Size, cmd.fileChanger.UploadOffset, fileOutputData.Size, cmd.fileChanger.Size)
178178
if err != nil {
179179
logging.Logger.Error("UploadFileCommand.ProcessContent", zap.Error(err))
180180
return result, err

0 commit comments

Comments
 (0)