Fix error with fs.DirExists()

It errors out when providing a subdirectory of a file, e.g. `index.md/.zk`
pull/90/head
Mickaël Menu 3 years ago
parent cfb337c967
commit 9bd2eacf06

@ -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) {

@ -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)

Loading…
Cancel
Save