Skip to content

Commit ebe7d3a

Browse files
committed
Merge branch 'feat/config-recover' of https://github.com/0chain/blobber into feat/config-recover
2 parents 273e376 + 327d982 commit ebe7d3a

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,6 @@ func GetAllocationChanges(ctx context.Context, connectionID, allocationID, clien
161161
cc.ComputeProperties()
162162
// Load connection Obj size from memory
163163
cc.Size = GetConnectionObjSize(connectionID)
164-
cc.Status = InProgressConnection
165164
return cc, nil
166165
}
167166

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ func cleanupTempFiles(ctx context.Context) {
7979
then := now.Add(time.Duration(-config.Configuration.OpenConnectionWorkerTolerance) * time.Second)
8080

8181
var openConnectionsToDelete []allocation.AllocationChangeCollector
82-
db.Table((&allocation.AllocationChangeCollector{}).TableName()).Where("updated_at < ? AND status IN (?,?)", then, allocation.NewConnection, allocation.InProgressConnection).Preload("Changes").Find(&openConnectionsToDelete)
82+
db.Table((&allocation.AllocationChangeCollector{}).TableName()).Where("updated_at < ?", then).Preload("Changes").Find(&openConnectionsToDelete)
8383

8484
for i := 0; i < len(openConnectionsToDelete); i++ {
8585
connection := &openConnectionsToDelete[i]
@@ -93,10 +93,12 @@ func cleanupTempFiles(ctx context.Context) {
9393
nctx := datastore.GetStore().CreateTransaction(ctx)
9494
ndb := datastore.GetStore().GetTransaction(nctx)
9595
var errorOccurred bool
96-
for _, changeProcessor := range connection.AllocationChanges {
97-
if err := changeProcessor.DeleteTempFile(); err != nil {
98-
errorOccurred = true
99-
logging.Logger.Error("AllocationChangeProcessor_DeleteTempFile", zap.Error(err))
96+
if connection.Status == allocation.InProgressConnection || connection.Status == allocation.NewConnection {
97+
for _, changeProcessor := range connection.AllocationChanges {
98+
if err := changeProcessor.DeleteTempFile(); err != nil {
99+
errorOccurred = true
100+
logging.Logger.Error("AllocationChangeProcessor_DeleteTempFile", zap.Error(err))
101+
}
100102
}
101103
}
102104

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
-- +goose Up
2+
-- +goose StatementBegin
3+
4+
DELETE FROM allocation_connections WHERE status = 2 OR status = 3;
5+
6+
-- +goose StatementEnd

0 commit comments

Comments
 (0)