satellite/metainfo: make piece hashes nil before storing pointer in metainfo.UpdatePieces() (#3050)

This commit is contained in:
Maximillian von Briesen 2019-09-16 12:11:12 -04:00 committed by GitHub
parent 0c2ae7786e
commit 7ada5d4152
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 3 deletions

View File

@ -92,9 +92,7 @@ func (s *Service) UpdatePieces(ctx context.Context, path string, ref *pb.Pointer
continue
}
existing := pieceMap[piece.PieceNum]
if existing != nil &&
existing.NodeId == piece.NodeId &&
existing.Hash == piece.Hash {
if existing != nil && existing.NodeId == piece.NodeId {
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
var pieces []*pb.RemotePiece
for _, piece := range pieceMap {
// clear hashes so we don't store them
piece.Hash = nil
pieces = append(pieces, piece)
}
pointer.GetRemote().RemotePieces = pieces

View File

@ -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, 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
// download from the new nodes that the repaired pieces have been uploaded
if _, ok := nodesToKeepAlive[piece.NodeId]; ok && nodesToKillForMinThreshold > 0 {