Skip to content

Commit

Permalink
Fix error with fs.DirExists()
Browse files Browse the repository at this point in the history
It errors out when providing a subdirectory of a file, e.g. `index.md/.zk`
  • Loading branch information
mickael-menu committed Oct 11, 2021
1 parent cfb337c commit 9bd2eac
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
6 changes: 1 addition & 5 deletions internal/adapter/fs/fs.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,7 @@ func (fs *FileStorage) FileExists(path string) (bool, error) {

func (fs *FileStorage) DirExists(path string) (bool, error) {
fi, err := fs.fileInfo(path)
if err != nil {
return false, err
} else {
return fi != nil && (*fi).Mode().IsDir(), nil
}
return !os.IsNotExist(err) && fi != nil && (*fi).Mode().IsDir(), nil
}

func (fs *FileStorage) fileInfo(path string) (*os.FileInfo, error) {
Expand Down
2 changes: 1 addition & 1 deletion internal/core/notebook_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func (e ErrNotebookNotFound) Error() string {
// Open returns a new Notebook instance for the notebook containing the
// given file path.
func (ns *NotebookStore) Open(path string) (*Notebook, error) {
wrap := errors.Wrapper("open failed")
wrap := errors.Wrapper("failed to open notebook")

path = ns.fs.Canonical(path)
nb := ns.cachedNotebookAt(path)
Expand Down

0 comments on commit 9bd2eac

Please sign in to comment.