Skip to content
This repository has been archived by the owner on Jun 26, 2023. It is now read-only.

Fix/minimize rebuild #15

Merged
merged 9 commits into from
Jul 29, 2021
10 changes: 5 additions & 5 deletions dspinner/pin.go
Original file line number Diff line number Diff line change
Expand Up @@ -981,15 +981,15 @@ func (p *pinner) rebuildIndexes(ctx context.Context) error {
indexer = p.cidRIndex
// Delete any direct index
err = p.cidDIndex.Delete(ctx, indexKey, pp.Id)
log.Infof("deleting stale pin index for cid %v", pp.Cid.String())
log.Errorf("deleting stale pin index for cid %v", pp.Cid.String())
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This appears to log the error message whether or not a stale pin was actually found. Perhaps Delete needs to return a boolean, or there should be a find for the pin first.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's not log deletions for now. I'll update the PR.

if err != nil {
return err
}
} else if pp.Mode == ipfspinner.Direct {
indexer = p.cidDIndex
// Delete any recursive index
err = p.cidRIndex.Delete(ctx, indexKey, pp.Id)
log.Infof("deleting stale pin index for cid %v", pp.Cid.String())
log.Errorf("deleting stale pin index for cid %v", pp.Cid.String())
if err != nil {
return err
}
Expand All @@ -1012,7 +1012,7 @@ func (p *pinner) rebuildIndexes(ctx context.Context) error {
return err
}
if !ok {
log.Infof("repairing pin index for cid: %s", pp.Cid.String())
log.Errorf("repairing pin index for cid: %s", pp.Cid.String())
// There was no index found for this pin. This was either an
// incomplete add or and incomplete delete of a pin. Either
// way, restore the index to complete the add or to undo the
Expand All @@ -1030,7 +1030,7 @@ func (p *pinner) rebuildIndexes(ctx context.Context) error {
return err
}
if !ok {
log.Infof("repairing pin name for cid: %s", pp.Cid.String())
log.Errorf("repairing pin name for cid: %s", pp.Cid.String())
if err = p.nameIndex.Add(ctx, pp.Name, pp.Id); err != nil {
return err
}
Expand All @@ -1047,6 +1047,6 @@ func (p *pinner) rebuildIndexes(ctx context.Context) error {
}
}

log.Infof("checked %d pins for invalid indexes, repaired %d pins", checkedCount, repairedCount)
log.Errorf("checked %d pins for invalid indexes, repaired %d pins", checkedCount, repairedCount)
return p.flushPins(ctx, true)
}