Skip to content
Snippets Groups Projects
Commit 7b302f78 authored by Jake Taylor's avatar Jake Taylor
Browse files

change os.ISNotExist to use updated call

parent 3ca98677
No related branches found
No related tags found
3 merge requests!510Release,!207WIP: Client Restructure,!203Symmetric broadcast
......@@ -13,8 +13,10 @@ import (
"encoding/binary"
"encoding/hex"
"encoding/json"
"errors"
"fmt"
"gitlab.com/elixxir/client/cmix"
"io/fs"
"io/ioutil"
"log"
"os"
......@@ -536,7 +538,7 @@ func createClient() *api.Client {
backupPass := []byte(viper.GetString("backupPass"))
// create a new client if none exist
if _, err := os.Stat(storeDir); os.IsNotExist(err) {
if _, err := os.Stat(storeDir); errors.Is(err, fs.ErrNotExist) {
// Load NDF
ndfJSON, err := ioutil.ReadFile(viper.GetString("ndf"))
if err != nil {
......
......@@ -11,7 +11,7 @@ import (
"encoding/json"
"github.com/pkg/errors"
"io"
"os"
"io/fs"
"sync"
"time"
......@@ -85,7 +85,7 @@ func NewOrLoadTracker(session storage.Session, addrSpace address.Space) *manager
// Load this structure
err := t.load()
if err != nil && os.IsNotExist(err) {
if err != nil && errors.Is(err, fs.ErrNotExist) {
oldTimestamp, err2 := getOldTimestampStore(t.session)
if err2 == nil {
jww.WARN.Printf("No tracked identities found, creating a new " +
......
......@@ -2,7 +2,6 @@ package e2e
import (
"encoding/json"
"fmt"
"strings"
"time"
......@@ -95,7 +94,6 @@ func LoadLegacy(kv *versioned.KV, net cmix.Client, myID *id.ID,
// this would be a case where LoadLegacy is most likely not the correct
// code-path the caller should be following.
if _, err := kv.Get(e2eRekeyParamsKey, e2eRekeyParamsVer); err != nil && !strings.Contains(err.Error(), "object not found") {
fmt.Printf("err: %v", err)
return nil, errors.New("E2E rekey params are already on disk, " +
"LoadLegacy should not be called")
}
......
......@@ -14,8 +14,8 @@ import (
"gitlab.com/elixxir/client/storage/versioned"
"gitlab.com/xx_network/primitives/id"
"gitlab.com/xx_network/primitives/netTime"
"io/fs"
"math"
"os"
"strings"
"sync"
)
......@@ -51,7 +51,7 @@ type conversationDisk struct {
// saved to KV, and returned.
func LoadOrMakeConversation(kv *versioned.KV, partner *id.ID) *Conversation {
c, err := loadConversation(kv, partner)
if err != nil && !(os.IsNotExist(err) || strings.Contains(err.Error(), "object not found")) {
if err != nil && !(errors.Is(err, fs.ErrNotExist) || strings.Contains(err.Error(), "object not found")) {
jww.FATAL.Panicf("Failed to load conversation from storage: %+v", err)
} else if c == nil {
// Create new conversation and save to KV if one does not exist
......
......@@ -8,6 +8,7 @@ import (
"gitlab.com/elixxir/client/storage/versioned"
"gitlab.com/elixxir/primitives/fact"
"gitlab.com/xx_network/primitives/netTime"
"io/fs"
"strings"
)
......@@ -113,7 +114,7 @@ func NewOrLoadStore(kv *versioned.KV) (*Store, error) {
if err := s.load(); err != nil {
if strings.Contains(err.Error(), "object not found") ||
strings.Contains(err.Error(), "no such file or directory") {
errors.Is(err, fs.ErrNotExist) {
return s, s.save()
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment