Skip to content

Commit

Permalink
Prevent segfault
Browse files Browse the repository at this point in the history
  • Loading branch information
dmerrill6 committed Oct 23, 2020
1 parent ab2b4b7 commit 3968a4d
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions core/textile/model/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,17 +89,17 @@ func (m *model) findOrCreateMetaThreadID(ctx context.Context) (*thread.ID, error
}
hubmaWithThreadID := hubmaStr + "/thread/" + threadID.String()

// If we are here, then there's no replicated metathread yet
if _, err := utils.FindOrCreateDeterministicThreadID(ctx, utils.MetathreadThreadVariant, metaThreadName, m.kc, m.st, m.threads); err != nil {
return nil, err
}

// Try to join remote db if it was already replicated
err = m.threads.NewDBFromAddr(ctx, cmd.AddrFromStr(hubmaWithThreadID), key)
if err == nil || err.Error() == "rpc error: code = Unknown desc = db already exists" {
return &threadID, nil
}

// If we are here, then there's no replicated metathread yet
if _, err := utils.FindOrCreateDeterministicThreadID(ctx, utils.MetathreadThreadVariant, metaThreadName, m.kc, m.st, m.threads); err != nil {
return nil, err
}

if _, err := m.netc.AddReplicator(ctx, threadID, hubma); err != nil {
log.Error("error while replicating metathread", err)
// Not returning error in case the user is offline (it should still work using local threads)
Expand Down

0 comments on commit 3968a4d

Please sign in to comment.