2 Commits
v1.15 ... v1.17

Author SHA1 Message Date
Bel LaPointe
5a16beb676 symlinks ok 2021-02-25 22:27:10 -06:00
Bel LaPointe
817fc57dd1 dont search attachments or git 2021-02-25 22:23:13 -06:00

View File

@@ -57,7 +57,7 @@ func (n *Notes) Search(phrase string) (string, error) {
if err != nil {
return err
}
if info.IsDir() {
if !info.Mode().IsRegular() {
return nil
}
if size := info.Size(); size < 1 || size > (5*1024*1024) {
@@ -67,12 +67,11 @@ func (n *Notes) Search(phrase string) (string, error) {
if err != nil && err.Error() == "bufio.Scanner: token too long" {
err = nil
}
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)
} else if ok {
p := filetree.NewPathFromLocal(path.Dir(walked))
files.Push(p, info)
}
return err
},
@@ -81,6 +80,12 @@ func (n *Notes) Search(phrase string) (string, error) {
}
func grepFile(file string, searcher *searcher) (bool, error) {
if d := path.Base(path.Dir(file)); strings.HasPrefix(d, ".") && strings.HasSuffix(d, ".attachments") {
return false, nil
}
if strings.Contains(file, "/.git/") {
return false, nil
}
f, err := os.Open(file)
if err != nil {
return false, err