Compare commits

..
17 Commits
Author SHA1 Message Date
Pierre Dubouilh 698f3ffaf8 bump ui 2019-12-13 00:45:41 +01:00
Pierre Dubouilh dc1011bb5f remove remote state 2019-12-13 00:45:21 +01:00
Pierre Dubouilh 5096f46ba4 ci ping 2019-11-06 19:08:06 +01:00
Pierre Dubouilh f77b10d3de last refactor 2019-11-04 19:28:17 +01:00
Pierre Dubouilh ccd6ae2bea merge master 2019-10-15 19:53:03 +02:00
Pierre Dubouilh 858d30be9b bump ui 2019-10-15 19:40:03 +02:00
Pierre Dubouilh 0b586c5df9 small refactor 2019-10-15 19:39:42 +02:00
Pierre Dubouilh d913176daa tests & bump ui 2019-09-12 21:23:07 +02:00
Pierre Dubouilh beac60f3d8 readme 2019-09-12 21:23:07 +02:00
Pierre Dubouilh da7f60d5fc lock global 2019-09-12 21:23:06 +02:00
Pierre Dubouilh 39d2d4b13f bump ui 2019-09-09 22:09:27 +02:00
Pierre Dubouilh ec7168e718 shift hash setup 2019-09-08 18:13:08 +02:00
Pierre Dubouilh 95f01e47dd bump ui 2019-09-07 11:47:41 +02:00
Pierre Dubouilh c9266d8849 fix hidden files 2019-09-07 11:47:41 +02:00
Pierre Dubouilh e257d1145d hash state 2019-09-07 11:47:41 +02:00
Pierre Dubouilh 698a418e5d maintain state 2019-09-07 11:47:41 +02:00
Pierre Dubouilh e9eb3bf45b test all the extensions 2019-09-04 22:54:20 +02:00
6 changed files with 27 additions and 32 deletions
+2 -2
View File
@@ -7,10 +7,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.13
- name: Set up Go 1.12
uses: actions/setup-go@v1
with:
go-version: 1.13
go-version: 1.12
id: go
- name: Check out code into the Go module directory
+6 -16
View File
@@ -3,7 +3,7 @@ build:
make -C gossa-ui/
go vet && go fmt
CGO_ENABLED=0 go build gossa.go
sleep 1 && rm gossa.go
rm gossa.go
run:
make build
@@ -13,23 +13,13 @@ run-extra:
make build
./gossa -verb=true -prefix="/fancy-path/" -k=false -symlinks=true test-fixture
test:
timeout 60 make run &
sleep 15 && cp src/gossa_test.go . && go test -run TestNormal
rm gossa_test.go
-killall gossa
test-extra:
timeout 60 make run-extra &
sleep 15 && cp src/gossa_test.go . && go test -run TestExtra
rm gossa_test.go
-killall gossa
ci:
-@cd test-fixture && ln -s ../support .
make test
make test-extra
make build
timeout 15 make run &
sleep 16 && timeout 15 make run-extra &
cp src/gossa_test.go . && go test
rm gossa_test.go
watch:
ls src/* gossa-ui/* | entr -rc make run
+1 -1
View File
@@ -1,7 +1,7 @@
gossa
=============
![e](https://user-images.githubusercontent.com/760637/71449335-790a4200-274a-11ea-80be-4c536fbad8a1.gif)
![e](https://user-images.githubusercontent.com/760637/64541706-a3163080-d322-11e9-85ef-a4d8001fa6a5.gif)
[![build status](https://github.com/pldubouilh/gossa/workflows/ci/badge.svg)](https://github.com/pldubouilh/gossa/actions)
[![docker build status](https://img.shields.io/docker/cloud/build/pldubouilh/gossa.svg?logo=docker)](https://hub.docker.com/r/pldubouilh/gossa)
+6 -6
View File
@@ -20,6 +20,7 @@ import (
var host = flag.String("h", "127.0.0.1", "host to listen to")
var port = flag.String("p", "8001", "port to listen to")
var history = flag.Bool("history", true, "keep history for paths visited. default location is path/.gossa_history")
var extraPath = flag.String("prefix", "/", "url prefix at which gossa can be reached, e.g. /gossa/ (slashes of importance)")
var symlinks = flag.Bool("symlinks", false, "follow symlinks \033[4mWARNING\033[0m: symlinks will by nature allow to escape the defined path (default: false)")
var verb = flag.Bool("verb", false, "verbosity")
@@ -76,10 +77,9 @@ func humanize(bytes int64) string {
}
}
func replyList(w http.ResponseWriter, fullPath string, path string) {
func replyList(w http.ResponseWriter, r *http.Request, fullPath string, path string) {
_files, err := ioutil.ReadDir(fullPath)
check(err)
if !strings.HasSuffix(path, "/") {
path += "/"
}
@@ -105,8 +105,7 @@ func replyList(w http.ResponseWriter, fullPath string, path string) {
p.RowsFolders = append(p.RowsFolders, rowTemplate{el.Name() + "/", template.HTML(href), "", "folder"})
} else {
sl := strings.Split(el.Name(), ".")
ext := strings.ToLower(sl[len(sl)-1])
p.RowsFiles = append(p.RowsFiles, rowTemplate{el.Name(), template.HTML(href), humanize(el.Size()), ext})
p.RowsFiles = append(p.RowsFiles, rowTemplate{el.Name(), template.HTML(href), humanize(el.Size()), strings.ToLower(sl[len(sl)-1])})
}
}
@@ -126,7 +125,7 @@ func doContent(w http.ResponseWriter, r *http.Request) {
check(errStat)
if stat.IsDir() {
replyList(w, fullPath, path)
replyList(w, r, fullPath, path)
} else {
fs.ServeHTTP(w, r)
}
@@ -148,6 +147,7 @@ func rpc(w http.ResponseWriter, r *http.Request) {
bodyBytes, _ := ioutil.ReadAll(r.Body)
json.Unmarshal(bodyBytes, &rpc)
defer exitPath(w, "rpc", rpc)
ret := "ok"
if rpc.Call == "mkdirp" {
err = os.MkdirAll(checkPath(rpc.Args[0]), os.ModePerm)
@@ -158,7 +158,7 @@ func rpc(w http.ResponseWriter, r *http.Request) {
}
check(err)
w.Write([]byte("ok"))
w.Write([]byte(ret))
}
func checkPath(p string) string {
+11 -6
View File
@@ -8,6 +8,7 @@ import (
"regexp"
"strings"
"testing"
"time"
)
func dieMaybe(t *testing.T, err error) {
@@ -230,14 +231,18 @@ func doTest(t *testing.T, url string, testExtra bool) {
}
}
func TestNormal(t *testing.T) {
func TestGetFolder(t *testing.T) {
time.Sleep(6 * time.Second)
fmt.Println("========== testing normal path ============")
doTest(t, "http://127.0.0.1:8001/", false)
fmt.Printf("\r\n=========\r\n")
}
url := "http://127.0.0.1:8001/"
doTest(t, url, false)
func TestExtra(t *testing.T) {
fmt.Printf("\r\n=========\r\n")
time.Sleep(10 * time.Second)
url = "http://127.0.0.1:8001/fancy-path/"
fmt.Println("========== testing at fancy path ============")
doTest(t, "http://127.0.0.1:8001/fancy-path/", true)
doTest(t, url, true)
fmt.Printf("\r\n=========\r\n")
}