satellite/metainfo: make piece hashes nil before storing pointer in metainfo.UpdatePieces() (#3050)
This commit is contained in:
parent
0c2ae7786e
commit
7ada5d4152
@ -92,9 +92,7 @@ func (s *Service) UpdatePieces(ctx context.Context, path string, ref *pb.Pointer
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
existing := pieceMap[piece.PieceNum]
|
existing := pieceMap[piece.PieceNum]
|
||||||
if existing != nil &&
|
if existing != nil && existing.NodeId == piece.NodeId {
|
||||||
existing.NodeId == piece.NodeId &&
|
|
||||||
existing.Hash == piece.Hash {
|
|
||||||
delete(pieceMap, piece.PieceNum)
|
delete(pieceMap, piece.PieceNum)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -114,6 +112,8 @@ func (s *Service) UpdatePieces(ctx context.Context, path string, ref *pb.Pointer
|
|||||||
// copy the pieces from the map back to the pointer
|
// copy the pieces from the map back to the pointer
|
||||||
var pieces []*pb.RemotePiece
|
var pieces []*pb.RemotePiece
|
||||||
for _, piece := range pieceMap {
|
for _, piece := range pieceMap {
|
||||||
|
// clear hashes so we don't store them
|
||||||
|
piece.Hash = nil
|
||||||
pieces = append(pieces, piece)
|
pieces = append(pieces, piece)
|
||||||
}
|
}
|
||||||
pointer.GetRemote().RemotePieces = pieces
|
pointer.GetRemote().RemotePieces = pieces
|
||||||
|
@ -147,6 +147,8 @@ func TestDataRepair(t *testing.T) {
|
|||||||
require.NotContains(t, nodesToKill, piece.NodeId, "there shouldn't be pieces in killed nodes")
|
require.NotContains(t, nodesToKill, piece.NodeId, "there shouldn't be pieces in killed nodes")
|
||||||
require.NotContains(t, nodesToDisqualify, piece.NodeId, "there shouldn't be pieces in DQ nodes")
|
require.NotContains(t, nodesToDisqualify, piece.NodeId, "there shouldn't be pieces in DQ nodes")
|
||||||
|
|
||||||
|
require.Nil(t, piece.Hash, "piece hashes should be set to nil")
|
||||||
|
|
||||||
// Kill the original nodes which were kept alive to ensure that we can
|
// Kill the original nodes which were kept alive to ensure that we can
|
||||||
// download from the new nodes that the repaired pieces have been uploaded
|
// download from the new nodes that the repaired pieces have been uploaded
|
||||||
if _, ok := nodesToKeepAlive[piece.NodeId]; ok && nodesToKillForMinThreshold > 0 {
|
if _, ok := nodesToKeepAlive[piece.NodeId]; ok && nodesToKillForMinThreshold > 0 {
|
||||||
|
Loading…
Reference in New Issue
Block a user