Skip to content

Commit 2f877a4

Browse files
committed
Merge branch 'main' of https://github.com/csznet/goFile
2 parents 1e045d5 + 5ac8c80 commit 2f877a4

5 files changed

Lines changed: 24 additions & 32 deletions

File tree

.github/workflows/build-go.yml

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,13 @@ jobs:
99
runs-on: ubuntu-latest
1010
strategy:
1111
matrix:
12-
# goos: [linux, windows, darwin]
13-
# goarch: ["386", amd64, arm64]
14-
# exclude:
15-
# - goarch: "386"
16-
# goos: darwin
17-
# - goarch: arm64
18-
# goos: windows
19-
goos: [linux, darwin]
20-
goarch: [amd64, arm64]
12+
goos: [linux, darwin,windows]
13+
goarch: [amd64, arm64,"386"]
2114
exclude:
2215
- goarch: arm64
2316
goos: windows
17+
- goarch: "386"
18+
goos: darwin
2419
steps:
2520
- uses: actions/checkout@v3
2621
- uses: wangyoucao577/go-release-action@v1.36

README.md

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,12 @@ easy file manager
2929

3030
一键脚本
3131
===
32-
33-
bash <(curl -s https://raw.githubusercontent.com/csznet/goFile/main/goFile.sh)
32+
```shell
33+
curl -Lso- csz.net/script/goFile.sh | sudo bash
34+
```
3435

3536
一键脚本支持amd64、arm构架,Linux、MacOS系统
36-
Windows系统不会考虑(Windows就不需要去网页管理文件了吧
37+
<del>Windows系统不会考虑(Windows就不需要去网页管理文件了吧</del>
3738

3839
运行
3940
===
@@ -48,16 +49,17 @@ Windows系统不会考虑(Windows就不需要去网页管理文件了吧
4849

4950
参数
5051
===
52+
### 目录
5153
-path
5254

53-
目录,默认为./(一键脚本则为执行`goFile`命令的目录)
55+
文件目录,默认为./(一键脚本则为执行`goFile`命令的目录)
56+
### 端口
5457

5558
-port
5659

57-
web端口,默认为8089
60+
web端口,默认为8089
61+
### 只读
5862

5963
-r
6064

61-
带入`-r`参数后表示为阅读模式,只能查看列表和下载文件,后面不需要带值
62-
63-
带入`-t`参数代表打开缩略图(太鸡肋了,后面可能会删掉
65+
带入`-r`参数后表示为阅读模式,只能查看列表和下载文件,后面不需要带值

assets/templates/index.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727
{{range $item := .info.Files}}
2828
<li class="c-b">
2929
<a target="_blank" href="/download/{{.FilePath}}">{{$item.FileName}}</a>
30-
{{ if not $r }}
3130
<span class="f-r"><a target="_blank" href="/view/{{.FilePath}}">{{t "view"}}</a></span>
31+
{{ if not $r }}
3232
<span class="f-r"><a onclick="edite({{.FilePath}})">{{t "edit"}}</a></span>
3333
<span class="f-r"><a onclick="rm({{.FilePath}})">{{t "del"}}</a></span>
3434
{{if .IsZip}}

goFile.sh

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,16 @@ fi
4848
# 获取百度的平均延迟(ping 5次并取平均值)
4949
ping_result=$(ping -c 5 -q baidu.com | awk -F'/' 'END{print $5}')
5050

51-
# 判断平均延迟是否在100以内
52-
if (( $(echo "$ping_result < 100" | bc -l) )); then
51+
# 判断延迟是否在100以内
52+
if awk -v ping="$ping_result" 'BEGIN{exit !(ping < 100)}'; then
5353
echo "服务器位于中国国内,使用代理下载"
54-
url="https://ghproxy.com/https://github.com/csznet/goFile/releases/latest/download/${file_name}"
54+
url="https://mirror.ghproxy.com/https://github.com/csznet/goFile/releases/latest/download/${file_name}"
5555
else
5656
echo "服务器位于国外,不使用代理下载"
5757
url="https://github.com/csznet/goFile/releases/latest/download/${file_name}"
5858
fi
5959

60+
6061
# 下载文件并解压
6162

6263
curl -L -O $url
@@ -70,4 +71,4 @@ chmod +x goFile
7071
mv goFile /usr/local/bin/
7172

7273
# 提示用户
73-
echo -e "\033[34m在想调用出 goFile 管理的目录下直接执行 goFile 命令即可\033[0m"
74+
echo -e "\033[34m在想调用出 goFile 管理的目录下直接执行 goFile 命令即可\033[0m"

main.go

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,11 @@ func web() {
6161
})
6262
})
6363
r.GET("/view/*path", func(c *gin.Context) {
64-
cPath := strings.Replace(c.Param("path"), "/", "", 1)
65-
c.File(conf.GoFile + cPath)
64+
c.File(filepath.Join(conf.GoFile, filepath.Clean(c.Param("path"))))
6665
})
6766
r.GET("/download/*path", func(c *gin.Context) {
68-
cPath := strings.Replace(c.Param("path"), "/", "", 1)
69-
fileName := filepath.Base(cPath)
70-
c.FileAttachment(conf.GoFile+cPath, fileName)
67+
cPath := filepath.Clean(c.Param("path"))
68+
c.FileAttachment(filepath.Join(conf.GoFile, cPath), filepath.Base(cPath))
7169
})
7270
r.GET("/d/*path", func(c *gin.Context) {
7371
rawPath := c.Param("path")
@@ -233,12 +231,8 @@ func main() {
233231
if err == nil {
234232
conf.GoFile = cwd
235233
}
236-
} else {
237-
conf.GoFile = strings.Replace(conf.GoFile, "./", "", 1)
238-
}
239-
if conf.GoFile[len(conf.GoFile)-1] != '/' {
240-
conf.GoFile = conf.GoFile + "/"
241234
}
235+
conf.GoFile = filepath.Clean(conf.GoFile) + "/"
242236
fmt.Println("Run Directory:" + conf.GoFile)
243237
fmt.Println("goFile Port is " + conf.GoFilePort)
244238
web()

0 commit comments

Comments
 (0)