Fix error if history file doesn't exist

This commit is contained in:
Ingo Oppermann
2023-07-19 13:17:55 +02:00
parent 165db9dc96
commit c1b47036d6
3 changed files with 37 additions and 6 deletions

View File

@@ -2,6 +2,7 @@ package session
import (
"bytes"
"errors"
"io"
"os"
@@ -39,8 +40,12 @@ func NewHistorySource(fs fs.Filesystem, path string) (SnapshotSource, error) {
path: path,
}
if _, err := s.fs.Stat(s.path); err == os.ErrNotExist {
return nil, nil
if _, err := s.fs.Stat(s.path); err != nil {
if errors.Is(err, os.ErrNotExist) {
return nil, nil
}
return nil, err
}
data, err := s.fs.ReadFile(s.path)