cmd/segment-reaper: Use bitmask type in observer (#3661)
bitmask type was created for making easy to understand the observer bit logic. This commit makes the changes in observer for using the bitmask type.
This commit is contained in:
parent
7288d01781
commit
0bf7ac5b20
@ -20,7 +20,7 @@ import (
|
||||
// object represents object with segments.
|
||||
type object struct {
|
||||
// TODO verify if we have more than 64 segments for object in network
|
||||
segments uint64
|
||||
segments bitmask
|
||||
|
||||
expectedNumberOfSegments byte
|
||||
|
||||
@ -112,12 +112,19 @@ func (obsvr *observer) processSegment(ctx context.Context, path metainfo.ScopedP
|
||||
zap.S().Warn("unsupported segment index", zap.Int("index", segmentIndex))
|
||||
}
|
||||
|
||||
if object.segments&(1<<uint64(segmentIndex)) != 0 {
|
||||
ok, err := object.segments.Has(segmentIndex)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if ok {
|
||||
// TODO make path displayable
|
||||
return errs.New("fatal error this segment is duplicated: %s", path.Raw)
|
||||
}
|
||||
|
||||
object.segments |= 1 << uint64(segmentIndex)
|
||||
err = object.segments.Set(segmentIndex)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
// collect number of pointers for report
|
||||
|
Loading…
Reference in New Issue
Block a user