Ensure new directory exists before unwatching old

This commit is contained in:
Galen Abell 2020-02-25 16:35:57 -05:00 committed by Drew DeVault
parent 2fcd77f101
commit 5ba1569734
1 changed files with 6 additions and 5 deletions

View File

@ -236,6 +236,12 @@ func (w *Worker) handleListDirectories(msg *types.ListDirectories) error {
func (w *Worker) handleOpenDirectory(msg *types.OpenDirectory) error { func (w *Worker) handleOpenDirectory(msg *types.OpenDirectory) error {
w.worker.Logger.Printf("opening %s", msg.Directory) w.worker.Logger.Printf("opening %s", msg.Directory)
// open the directory
dir, err := w.c.OpenDirectory(msg.Directory)
if err != nil {
return err
}
// remove existing watch path // remove existing watch path
if w.selected != nil { if w.selected != nil {
prevDir := filepath.Join(string(*w.selected), "new") prevDir := filepath.Join(string(*w.selected), "new")
@ -244,11 +250,6 @@ func (w *Worker) handleOpenDirectory(msg *types.OpenDirectory) error {
} }
} }
// open the directory
dir, err := w.c.OpenDirectory(msg.Directory)
if err != nil {
return err
}
w.selected = &dir w.selected = &dir
w.selectedName = msg.Directory w.selectedName = msg.Directory