Skip to content
This repository has been archived by the owner on Aug 2, 2021. It is now read-only.

Commit

Permalink
storage/localstore: invert condition to prevent test coupling
Browse files Browse the repository at this point in the history
  • Loading branch information
acud committed Sep 30, 2019
1 parent 0750fea commit c080aca
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions storage/localstore/mode_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ func (db *DB) Set(ctx context.Context, mode chunk.ModeSet, addrs ...chunk.Addres

metrics.GetOrRegisterCounter(metricName, nil).Inc(1)
defer totalTimeMetric(metricName, time.Now())

err = db.set(mode, addrs...)
if err != nil {
metrics.GetOrRegisterCounter(metricName+".error", nil).Inc(1)
Expand Down Expand Up @@ -80,6 +79,7 @@ func (db *DB) set(mode chunk.ModeSet, addrs ...chunk.Address) (err error) {

case chunk.ModeSetSyncPush, chunk.ModeSetSyncPull:
for _, addr := range addrs {

c, err := db.setSync(batch, addr, mode)
if err != nil {
return err
Expand Down Expand Up @@ -217,7 +217,7 @@ func (db *DB) setSync(batch *leveldb.Batch, addr chunk.Address, mode chunk.ModeS

// moveToGc toggles the deletion of the item from pushsync index
// it will be false in the case pull sync was called but push sync was meant on that chunk (!tag.Anonymous)
moveToGc := false
moveToGc := true

if db.tags != nil {
i, err = db.pushIndex.Get(item)
Expand All @@ -231,11 +231,11 @@ func (db *DB) setSync(batch *leveldb.Batch, addr chunk.Address, mode chunk.ModeS
// this will not get called twice because we remove the item once after the !moveToGc check
tag.Inc(chunk.StateSent)
tag.Inc(chunk.StateSynced)
moveToGc = true
} else {
moveToGc = false
}
case chunk.ModeSetSyncPush:
tag.Inc(chunk.StateSynced)
moveToGc = true
}
}
case leveldb.ErrNotFound:
Expand Down

0 comments on commit c080aca

Please sign in to comment.