@@ -646,13 +646,17 @@ func (fsh *StorageHandler) CommitWrite(ctx context.Context, r *http.Request) (*b
646646 Logger .Error ("Error checking pending markers" , zap .Error (err ))
647647 return nil , common .NewError ("pending_markers" , "previous marker is still pending to be redeemed" )
648648 }
649-
649+ var result blobberhttp. CommitResult
650650 connectionObj , err := allocation .GetAllocationChanges (ctx , connectionID , allocationID , clientID )
651651 if err != nil {
652652 // might be good to check if blobber already has stored writemarker
653653 return nil , common .NewErrorf ("invalid_parameters" ,
654654 "Invalid connection id. Connection id was not found: %v" , err )
655655 }
656+ if connectionObj .Status == allocation .CommittedConnection {
657+ result .Success = true
658+ return & result , nil
659+ }
656660 if len (connectionObj .Changes ) == 0 {
657661 if connectionObj .Status == allocation .NewConnection {
658662 return nil , common .NewError ("invalid_parameters" ,
@@ -680,7 +684,6 @@ func (fsh *StorageHandler) CommitWrite(ctx context.Context, r *http.Request) (*b
680684 err )
681685 }
682686
683- var result blobberhttp.CommitResult
684687 var latestWriteMarkerEntity * writemarker.WriteMarkerEntity
685688 if allocationObj .AllocationRoot == "" {
686689 latestWriteMarkerEntity = nil
@@ -867,7 +870,6 @@ func (fsh *StorageHandler) CommitWrite(ctx context.Context, r *http.Request) (*b
867870
868871 //Delete connection object and its changes
869872
870- db .Delete (connectionObj )
871873 go allocation .DeleteConnectionObjEntry (connectionID )
872874 go AddWriteMarkerCount (clientID , connectionObj .Size <= 0 )
873875
@@ -936,13 +938,17 @@ func (fsh *StorageHandler) CommitWriteV2(ctx context.Context, r *http.Request) (
936938 Logger .Error ("Error checking pending markers" , zap .Error (err ))
937939 return nil , common .NewError ("pending_markers" , "previous marker is still pending to be redeemed" )
938940 }
939-
941+ var result blobberhttp. CommitResult
940942 connectionObj , err := allocation .GetAllocationChanges (ctx , connectionID , allocationID , clientID )
941943 if err != nil {
942944 // might be good to check if blobber already has stored writemarker
943945 return nil , common .NewErrorf ("invalid_parameters" ,
944946 "Invalid connection id. Connection id was not found: %v" , err )
945947 }
948+ if connectionObj .Status == allocation .CommittedConnection {
949+ result .Success = true
950+ return & result , nil
951+ }
946952 if len (connectionObj .Changes ) == 0 {
947953 if connectionObj .Status == allocation .NewConnection {
948954 return nil , common .NewError ("invalid_parameters" ,
@@ -970,7 +976,6 @@ func (fsh *StorageHandler) CommitWriteV2(ctx context.Context, r *http.Request) (
970976 err )
971977 }
972978
973- var result blobberhttp.CommitResult
974979 var latestWriteMarkerEntity * writemarker.WriteMarkerEntity
975980 if allocationObj .AllocationRoot == "" {
976981 latestWriteMarkerEntity = nil
@@ -1193,8 +1198,6 @@ func (fsh *StorageHandler) CommitWriteV2(ctx context.Context, r *http.Request) (
11931198 commitSuccess = true
11941199
11951200 //Delete connection object and its changes
1196-
1197- db .Delete (connectionObj )
11981201 go allocation .DeleteConnectionObjEntry (connectionID )
11991202 go AddWriteMarkerCount (clientID , connectionObj .Size <= 0 )
12001203
0 commit comments