Skip to content

Commit

Permalink
fix: prevent panic in case of nonexistent notes directory path in con…
Browse files Browse the repository at this point in the history
…fig file
  • Loading branch information
ptdewey committed Nov 28, 2024
1 parent 8b64c4e commit 09b5e1f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions internal/daemon/watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ func runNotesDirsWatcher(dirs ...string) error {
dirIgnores := config.IgnoredDirectories()

for _, dir := range dirs {
if _, err := os.Stat(dir); err != nil {
log.Printf("Error creating watcher on directory '%s': %v\n", dir, err)
continue
}

// TODO: add oolong ignore system to blacklist certain subdirs/files
if err = filepath.WalkDir(dir, func(path string, d fs.DirEntry, err error) error {
if !d.IsDir() {
Expand Down
6 changes: 6 additions & 0 deletions internal/documents/corpus.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"errors"
"io/fs"
"log"
"os"
"path/filepath"
"slices"
"sync"
Expand Down Expand Up @@ -41,6 +42,11 @@ func ReadNotesDirs() error {

docs := []*Document{}
for _, dir := range config.NotesDirPaths() {
if _, err := os.Stat(dir); err != nil {
log.Printf("Error reading directory '%s': %v\n", dir, err)
continue
}

// extract all note file paths from notes directory
paths := []string{}
// TODO: add oolong ignore system to blacklist certain subdirs/files
Expand Down

0 comments on commit 09b5e1f

Please sign in to comment.