Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
807072a77f | ||
|
|
081d50328f | ||
|
|
4e2b7b3c85 |
8
Dockerfile
Normal file → Executable file
8
Dockerfile
Normal file → Executable file
@@ -1,11 +1,8 @@
|
|||||||
|
FROM frolvlad/alpine-glibc:alpine-3.9_glibc-2.29
|
||||||
|
RUN apk update && apk add --no-cache ca-certificates git
|
||||||
|
|
||||||
FROM golang:1.13-alpine as certs
|
|
||||||
RUN apk update && apk add --no-cache ca-certificates
|
|
||||||
|
|
||||||
FROM busybox:glibc
|
|
||||||
RUN mkdir -p /var/log
|
RUN mkdir -p /var/log
|
||||||
WORKDIR /main
|
WORKDIR /main
|
||||||
COPY --from=certs /etc/ssl/certs /etc/ssl/certs
|
|
||||||
|
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
@@ -13,4 +10,3 @@ ENV GOPATH=""
|
|||||||
ENV MNT="/mnt/"
|
ENV MNT="/mnt/"
|
||||||
ENTRYPOINT ["/main/exec-notes-server"]
|
ENTRYPOINT ["/main/exec-notes-server"]
|
||||||
CMD []
|
CMD []
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,9 @@ type Paths []Path
|
|||||||
func (p Paths) List(full ...bool) string {
|
func (p Paths) List(full ...bool) string {
|
||||||
content := "<ul>\n"
|
content := "<ul>\n"
|
||||||
for _, path := range p {
|
for _, path := range p {
|
||||||
|
if len(path.Base) > 0 && path.Base[0] == '.' {
|
||||||
|
continue
|
||||||
|
}
|
||||||
if len(full) > 0 && full[0] {
|
if len(full) > 0 && full[0] {
|
||||||
content += path.FullLI() + "\n"
|
content += path.FullLI() + "\n"
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
0
main_test.go
Normal file → Executable file
0
main_test.go
Normal file → Executable file
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
10
notes/search.go
Normal file → Executable file
10
notes/search.go
Normal file → Executable file
@@ -4,6 +4,7 @@ import (
|
|||||||
"bufio"
|
"bufio"
|
||||||
"bytes"
|
"bytes"
|
||||||
"local/notes-server/filetree"
|
"local/notes-server/filetree"
|
||||||
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
@@ -19,11 +20,20 @@ func (n *Notes) Search(phrase string) (string, error) {
|
|||||||
if info.IsDir() {
|
if info.IsDir() {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
if size := info.Size(); size < 1 || size > (5*1024*1024) {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
ok, err := grepFile(walked, []byte(phrase))
|
ok, err := grepFile(walked, []byte(phrase))
|
||||||
|
if err != nil && err.Error() == "bufio.Scanner: token too long" {
|
||||||
|
err = nil
|
||||||
|
}
|
||||||
if err == nil && ok {
|
if err == nil && ok {
|
||||||
p := filetree.NewPathFromLocal(path.Dir(walked))
|
p := filetree.NewPathFromLocal(path.Dir(walked))
|
||||||
files.Push(p, info)
|
files.Push(p, info)
|
||||||
}
|
}
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("failed to scan %v: %v", walked, err)
|
||||||
|
}
|
||||||
return err
|
return err
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|||||||
10
notes/search_test.go
Normal file → Executable file
10
notes/search_test.go
Normal file → Executable file
@@ -42,3 +42,13 @@ func TestSearch(t *testing.T) {
|
|||||||
t.Fatal(v, result)
|
t.Fatal(v, result)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestSearchBigFiles(t *testing.T) {
|
||||||
|
n := New()
|
||||||
|
n.root = "/usr/local/bin"
|
||||||
|
|
||||||
|
_, err := n.Search("this file")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
0
server/.notes/notes.go
Normal file → Executable file
0
server/.notes/notes.go
Normal file → Executable file
0
server/html.go
Normal file → Executable file
0
server/html.go
Normal file → Executable file
0
server/notes.go
Normal file → Executable file
0
server/notes.go
Normal file → Executable file
0
versions/.versions.go
Normal file → Executable file
0
versions/.versions.go
Normal file → Executable file
0
versions/.versions_test.go
Normal file → Executable file
0
versions/.versions_test.go
Normal file → Executable file
2
versions/versions.go
Normal file → Executable file
2
versions/versions.go
Normal file → Executable file
@@ -13,6 +13,8 @@ type Versions struct {
|
|||||||
func New() (*Versions, error) {
|
func New() (*Versions, error) {
|
||||||
v := &Versions{}
|
v := &Versions{}
|
||||||
v.cmd("git", "init")
|
v.cmd("git", "init")
|
||||||
|
v.cmd("git", "config", "user.email", "user@user.user")
|
||||||
|
v.cmd("git", "config", "user.name", "user")
|
||||||
return v, nil
|
return v, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
0
versions/versions_test.go
Normal file → Executable file
0
versions/versions_test.go
Normal file → Executable file
0
wrapper.html
Normal file → Executable file
0
wrapper.html
Normal file → Executable file
Reference in New Issue
Block a user