Dont list hidden files and hopefully search files by ext only .md
This commit is contained in:
0
notes/delete.go
Normal file → Executable file
0
notes/delete.go
Normal file → Executable file
0
notes/delete_test.go
Normal file → Executable file
0
notes/delete_test.go
Normal file → Executable file
0
notes/notes.go
Normal file → Executable file
0
notes/notes.go
Normal file → Executable file
0
notes/notes_test.go
Normal file → Executable file
0
notes/notes_test.go
Normal file → Executable file
8
notes/search.go
Normal file → Executable file
8
notes/search.go
Normal file → Executable file
@@ -4,9 +4,11 @@ import (
|
||||
"bufio"
|
||||
"bytes"
|
||||
"local/notes-server/filetree"
|
||||
"log"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func (n *Notes) Search(phrase string) (string, error) {
|
||||
@@ -19,11 +21,17 @@ func (n *Notes) Search(phrase string) (string, error) {
|
||||
if info.IsDir() {
|
||||
return nil
|
||||
}
|
||||
if splits := strings.Split(info.Name(), "."); len(splits) > 1 && !(strings.HasSuffix(info.Name(), ".md") || strings.HasSuffix(info.Name(), ".txt")) {
|
||||
return nil
|
||||
}
|
||||
ok, err := grepFile(walked, []byte(phrase))
|
||||
if err == nil && ok {
|
||||
p := filetree.NewPathFromLocal(path.Dir(walked))
|
||||
files.Push(p, info)
|
||||
}
|
||||
if err != nil {
|
||||
log.Printf("failed to scan %v: %v", walked, err)
|
||||
}
|
||||
return err
|
||||
},
|
||||
)
|
||||
|
||||
0
notes/search_test.go
Normal file → Executable file
0
notes/search_test.go
Normal file → Executable file
Reference in New Issue
Block a user