Skip to content

Commit

Permalink
Ensure to make data dir if it doesn't exist
Browse files Browse the repository at this point in the history
  • Loading branch information
nakabonne committed Jul 3, 2021
1 parent a855017 commit 167b85e
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,14 +175,14 @@ func NewStorage(opts ...Option) (Storage, error) {
// TODO: Start WAL recovery, which means to create a new memoryPartition based on WAL entries
}

if err := os.MkdirAll(s.dataPath, fs.ModePerm); err != nil {
return nil, fmt.Errorf("failed to make data directory %s: %w", s.dataPath, err)
}
w, err := newFileWal(walPath)
if err != nil {
return nil, err
}
s.wal = w
if err := os.MkdirAll(s.dataPath, fs.ModePerm); err != nil {
return nil, fmt.Errorf("failed to make data directory %s: %w", s.dataPath, err)
}
files, err := ioutil.ReadDir(s.dataPath)
if err != nil {
return nil, fmt.Errorf("failed to open data directory: %w", err)
Expand Down Expand Up @@ -319,6 +319,9 @@ func (s *storage) Select(metric string, labels []Label, start, end int64) ([]*Da
continue
}
ps, err := part.selectDataPoints(metric, labels, start, end)
if errors.Is(err, ErrNoDataPoints) {
continue
}
if err != nil {
return nil, fmt.Errorf("failed to select data points: %w", err)
}
Expand Down

0 comments on commit 167b85e

Please sign in to comment.