Skip to content

Commit

Permalink
Merge pull request #29 from philippgille/switch-error-check
Browse files Browse the repository at this point in the history
Switch error check
  • Loading branch information
philippgille authored Mar 2, 2024
2 parents 576368e + e03e7bf commit ee92d94
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion db.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ package chromem

import (
"context"
"errors"
"fmt"
"io/fs"
"os"
"path/filepath"
"sync"
Expand Down Expand Up @@ -52,7 +54,7 @@ func NewPersistentDB(path string) (*DB, error) {
}

// If the directory doesn't exist, create it and return an empty DB.
if _, err := os.Stat(path); os.IsNotExist(err) {
if _, err := os.Stat(path); errors.Is(err, fs.ErrNotExist) {
err := os.MkdirAll(path, 0o700)
if err != nil {
return nil, fmt.Errorf("couldn't create persistence directory: %w", err)
Expand Down

0 comments on commit ee92d94

Please sign in to comment.