From 79e9b62f6d1431edc41c4f4a0b44b4da1d4e5342 Mon Sep 17 00:00:00 2001 From: Ivan Fraixedes Date: Tue, 23 Jul 2019 14:16:32 +0200 Subject: [PATCH] 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. --- pkg/storage/segments/repairer.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkg/storage/segments/repairer.go b/pkg/storage/segments/repairer.go index bab227bfc..9b58474ac 100644 --- a/pkg/storage/segments/repairer.go +++ b/pkg/storage/segments/repairer.go @@ -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)