Skip to content

Commit 2d7fcd9

Browse files
authored
Merge pull request #1429 from 0chain/update/sprint-1.15-staging
Update/sprint 1.15 staging
2 parents 44e6c2d + 8cd25ad commit 2d7fcd9

File tree

6 files changed

+14
-8
lines changed

6 files changed

+14
-8
lines changed

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

Lines changed: 4 additions & 1 deletion
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,6 +210,9 @@ func SaveFileChange(connectionID, pathHash, fileName string, cmd FileCommand, is
210210
Offset: offset,
211211
DataBytes: dataWritten,
212212
}, contentSize)
213+
if addSize != 0 {
214+
UpdateConnectionObjSize(connectionID, addSize)
215+
}
213216
} else {
214217
change.seqPQ.Push(seqpriorityqueue.UploadData{
215218
Offset: offset,

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,6 @@ func (cmd *UpdateFileCommand) ProcessContent(allocationObj *allocation.Allocatio
147147
if fileOutputData.ContentSize != cmd.fileChanger.Size {
148148
return result, common.NewError("upload_error", fmt.Sprintf("File size mismatch. Expected: %d, Actual: %d", cmd.fileChanger.Size, fileOutputData.ContentSize))
149149
}
150-
allocation.UpdateConnectionObjSize(connID, cmd.fileChanger.Size-cmd.existingFileRef.Size)
151150
}
152151

153152
if cmd.thumbFile != nil {
@@ -157,7 +156,7 @@ func (cmd *UpdateFileCommand) ProcessContent(allocationObj *allocation.Allocatio
157156
}
158157
}
159158

160-
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)
161160
if err != nil {
162161
return result, err
163162
}

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,6 @@ func (cmd *UploadFileCommand) ProcessContent(allocationObj *allocation.Allocatio
164164
if fileOutputData.ContentSize != cmd.fileChanger.Size {
165165
return result, common.NewError("upload_error", fmt.Sprintf("File size mismatch. Expected: %d, Actual: %d", cmd.fileChanger.Size, fileOutputData.ContentSize))
166166
}
167-
allocation.UpdateConnectionObjSize(connectionID, cmd.fileChanger.Size)
168167
}
169168

170169
if cmd.thumbFile != nil {
@@ -175,7 +174,7 @@ func (cmd *UploadFileCommand) ProcessContent(allocationObj *allocation.Allocatio
175174
}
176175
}
177176

178-
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)
179178
if err != nil {
180179
logging.Logger.Error("UploadFileCommand.ProcessContent", zap.Error(err))
181180
return result, err

code/go/0chain.net/blobbercore/reference/object.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ func DeleteObject(ctx context.Context, rootRef *Ref, allocationID, objPath strin
3535
return nil
3636
}
3737
parentPath, deleteFileName := filepath.Split(objPath)
38-
3938
rootRef.UpdatedAt = ts
4039
fields, err := common.GetPathFields(parentPath)
4140
if err != nil {
@@ -63,7 +62,8 @@ func DeleteObject(ctx context.Context, rootRef *Ref, allocationID, objPath strin
6362
}
6463

6564
for i, child := range dirRef.Children {
66-
if child.Name == deleteFileName {
65+
basePath := filepath.Base(child.Path)
66+
if basePath == deleteFileName || child.Path == objPath {
6767
dirRef.RemoveChild(i)
6868
break
6969
}

code/go/0chain.net/blobbercore/writemarker/worker.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ func tryAgain(md *markerData) {
256256

257257
// Can add more cases where we don't want to retry
258258
func retryRedeem(errString string) bool {
259-
return !strings.Contains(errString, "value not present") || !strings.Contains(errString, "Blobber is not part of the allocation")
259+
return !strings.Contains(errString, "value not present") && !strings.Contains(errString, "Blobber is not part of the allocation")
260260
}
261261

262262
func startCollector(ctx context.Context) {
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
-- +goose Up
2+
-- +goose StatementBegin
3+
ALTER TABLE reference_objects ALTER COLUMN name TYPE character varying(150),
4+
ALTER COLUMN name SET NOT NULL;
5+
-- +goose StatementEnd

0 commit comments

Comments
 (0)