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