Skip to content

Commit

Permalink
fix: allow _localHeads to be empty (#72)
Browse files Browse the repository at this point in the history
Signed-off-by: Guillaume Louvigny <[email protected]>
  • Loading branch information
glouvigny authored Oct 20, 2020
1 parent 377c974 commit 591ebe5
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions stores/basestore/base_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -329,18 +329,22 @@ func (b *BaseStore) Load(ctx context.Context, amount int) error {

var localHeads, remoteHeads []*entry.Entry
localHeadsBytes, err := b.Cache().Get(datastore.NewKey("_localHeads"))
if err != nil {
if err != nil && err != datastore.ErrNotFound {
span.AddEvent(ctx, "local-heads-load-failed")
return errors.Wrap(err, "unable to get local heads from cache")
}

span.AddEvent(ctx, "local-heads-unmarshall")
err = json.Unmarshal(localHeadsBytes, &localHeads)
if err != nil {
span.AddEvent(ctx, "local-heads-unmarshall-failed")
return errors.Wrap(err, "unable to unmarshal cached local heads")
err = nil

if localHeadsBytes != nil {
span.AddEvent(ctx, "local-heads-unmarshall")
err = json.Unmarshal(localHeadsBytes, &localHeads)
if err != nil {
span.AddEvent(ctx, "local-heads-unmarshall-failed")
b.logger.Warn("unable to unmarshal cached local heads", zap.Error(err))
}
span.AddEvent(ctx, "local-heads-unmarshalled")
}
span.AddEvent(ctx, "local-heads-unmarshalled")

remoteHeadsBytes, err := b.Cache().Get(datastore.NewKey("_remoteHeads"))
if err != nil && err != datastore.ErrNotFound {
Expand Down

0 comments on commit 591ebe5

Please sign in to comment.