Browse Source

Fix path to mail files for watching

Alexey Edelev 5 years ago
parent
commit
034ccb0652
1 changed files with 5 additions and 3 deletions
  1. 5 3
      mailscanner.go

+ 5 - 3
mailscanner.go

@@ -21,6 +21,7 @@ type MailScanner struct {
 // }
 
 func NewMailScanner(mailPath string) (ms *MailScanner) {
+	fmt.Printf("Add mail folder %s for watching\n", mailPath)
 	watcher, err := fsnotify.NewWatcher()
 	if err != nil {
 		log.Fatal(err)
@@ -36,9 +37,10 @@ func NewMailScanner(mailPath string) (ms *MailScanner) {
 	}
 
 	for _, f := range files {
-		if fileExists(f.Name()) {
-			fmt.Printf("Add mail file %s for watching\n", f.Name())
-			watcher.Add(f.Name())
+		fullPath := mailPath + "/" + f.Name()
+		if fileExists(fullPath) {
+			fmt.Printf("Add mail file %s for watching\n", fullPath)
+			watcher.Add(fullPath)
 		}
 	}