Skip to content

Commit

Permalink
Switch error check
Browse files Browse the repository at this point in the history
From old (not deprecated but discouraged) to new recommended one
  • Loading branch information
philippgille committed Mar 2, 2024
1 parent 576368e commit e03e7bf
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 e03e7bf

Please sign in to comment.