pkg/storage/segments: Clarify logic in Repair method (#2621)

Create a new variable rather than reusing the existing one because the
name of the existing one is confusing when reading the logic and it
requires more time that the logic doesn't have a bug.
This commit is contained in:
Ivan Fraixedes 2019-07-23 14:16:32 +02:00 committed by GitHub
parent cba008d7df
commit 79e9b62f6d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -216,16 +216,17 @@ func (repairer *Repairer) Repair(ctx context.Context, path storj.Path) (err erro
mon.FloatVal("healthy_ratio_after_repair").Observe(healthyRatioAfterRepair)
// if partial repair, include "unhealthy" pieces that are not duplicates
revisedPointerPieces := healthyPieces
if healthyLength < pointer.Remote.Redundancy.SuccessThreshold {
for _, p := range unhealthyPieces {
if _, ok := healthyMap[p.GetPieceNum()]; !ok {
healthyPieces = append(healthyPieces, p)
revisedPointerPieces = append(revisedPointerPieces, p)
}
}
}
// Update the remote pieces in the pointer
pointer.GetRemote().RemotePieces = healthyPieces
pointer.GetRemote().RemotePieces = revisedPointerPieces
// Update the segment pointer in the metainfo
return repairer.metainfo.Put(ctx, path, pointer)