error handling in heldamount cash and collector delete fixed
Change-Id: I8fe58c50f844a6b819eacc14a40bc5c67268ed5c
This commit is contained in:
parent
96c83eb0b8
commit
aa6afc3879
@ -51,10 +51,6 @@ func (e *Endpoint) GetPayStub(ctx context.Context, req *pb.GetHeldAmountRequest)
|
||||
}
|
||||
node, err := e.overlay.Get(ctx, peer.ID)
|
||||
if err != nil {
|
||||
if overlay.ErrNodeNotFound.Has(err) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
return nil, rpcstatus.Error(rpcstatus.Internal, err.Error())
|
||||
}
|
||||
|
||||
@ -107,7 +103,7 @@ func (e *Endpoint) GetAllPaystubs(ctx context.Context, req *pb.GetAllPaystubsReq
|
||||
node, err := e.overlay.Get(ctx, peer.ID)
|
||||
if err != nil {
|
||||
if overlay.ErrNodeNotFound.Has(err) {
|
||||
return nil, nil
|
||||
return &pb.GetAllPaystubsResponse{}, nil
|
||||
}
|
||||
|
||||
return nil, rpcstatus.Error(rpcstatus.Internal, err.Error())
|
||||
@ -173,10 +169,6 @@ func (e *Endpoint) GetPayment(ctx context.Context, req *pb.GetPaymentRequest) (_
|
||||
}
|
||||
node, err := e.overlay.Get(ctx, peer.ID)
|
||||
if err != nil {
|
||||
if overlay.ErrNodeNotFound.Has(err) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
return nil, rpcstatus.Error(rpcstatus.Internal, err.Error())
|
||||
}
|
||||
|
||||
@ -215,7 +207,7 @@ func (e *Endpoint) GetAllPayments(ctx context.Context, req *pb.GetAllPaymentsReq
|
||||
node, err := e.overlay.Get(ctx, peer.ID)
|
||||
if err != nil {
|
||||
if overlay.ErrNodeNotFound.Has(err) {
|
||||
return nil, nil
|
||||
return &pb.GetAllPaymentsResponse{}, nil
|
||||
}
|
||||
|
||||
return nil, rpcstatus.Error(rpcstatus.Internal, err.Error())
|
||||
|
@ -6,6 +6,8 @@ package collector
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"github.com/spacemonkeygo/monkit/v3"
|
||||
@ -94,6 +96,10 @@ func (service *Service) Collect(ctx context.Context, now time.Time) (err error)
|
||||
for _, expired := range infos {
|
||||
err := service.pieces.Delete(ctx, expired.SatelliteID, expired.PieceID)
|
||||
if err != nil {
|
||||
if os.IsNotExist(errors.Unwrap(err)) {
|
||||
service.log.Info("file does not exist", zap.Stringer("Satellite ID", expired.SatelliteID), zap.Stringer("Piece ID", expired.PieceID))
|
||||
continue
|
||||
}
|
||||
errfailed := service.pieces.DeleteFailed(ctx, expired, now)
|
||||
if errfailed != nil {
|
||||
service.log.Error("unable to update piece info", zap.Stringer("Satellite ID", expired.SatelliteID), zap.Stringer("Piece ID", expired.PieceID), zap.Error(errfailed))
|
||||
|
Loading…
Reference in New Issue
Block a user