v1.1.13
This commit is contained in:
parent
4d282304d7
commit
9b0e21775a
2
Makefile
2
Makefile
|
|
@ -1,4 +1,4 @@
|
||||||
TAG ?= v1.1.12
|
TAG ?= v1.1.13
|
||||||
IMAGE_TAG ?= docker.educg.net/cg/k8s-manager:$(TAG)
|
IMAGE_TAG ?= docker.educg.net/cg/k8s-manager:$(TAG)
|
||||||
|
|
||||||
build: export CGO_ENABLED=0
|
build: export CGO_ENABLED=0
|
||||||
|
|
|
||||||
|
|
@ -16,9 +16,11 @@ func GetFiles(c *gin.Context) {
|
||||||
dirPath := path.Join(config.NFSPath, username, appName)
|
dirPath := path.Join(config.NFSPath, username, appName)
|
||||||
dir, err := os.ReadDir(dirPath)
|
dir, err := os.ReadDir(dirPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.WithError(err).Error("Cannot ReadDir ", dirPath)
|
if !os.IsNotExist(err) {
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"ok": false, "msg": err})
|
log.WithError(err).Error("Cannot ReadDir ", dirPath)
|
||||||
return
|
c.JSON(http.StatusBadRequest, gin.H{"ok": false, "msg": err})
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
c.JSON(http.StatusOK, gin.H{"ok": true, "files": funk.Map(dir, func(d fs.DirEntry) string { return d.Name() }).([]string)})
|
c.JSON(http.StatusOK, gin.H{"ok": true, "files": funk.Map(dir, func(d fs.DirEntry) string { return d.Name() }).([]string)})
|
||||||
}
|
}
|
||||||
|
|
@ -27,6 +29,7 @@ func GetPostOrDeleteFile(c *gin.Context) {
|
||||||
username := c.MustGet("username").(string)
|
username := c.MustGet("username").(string)
|
||||||
appName := c.Param("app")
|
appName := c.Param("app")
|
||||||
fileName := c.Param("filename")
|
fileName := c.Param("filename")
|
||||||
|
dirPath := path.Join(config.NFSPath, username, appName)
|
||||||
filePath := path.Join(config.NFSPath, username, appName, fileName)
|
filePath := path.Join(config.NFSPath, username, appName, fileName)
|
||||||
if c.Request.Method == http.MethodGet {
|
if c.Request.Method == http.MethodGet {
|
||||||
c.FileAttachment(filePath, fileName)
|
c.FileAttachment(filePath, fileName)
|
||||||
|
|
@ -37,6 +40,12 @@ func GetPostOrDeleteFile(c *gin.Context) {
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"ok": false, "msg": err})
|
c.JSON(http.StatusBadRequest, gin.H{"ok": false, "msg": err})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if _, err := os.Stat(dirPath); os.IsNotExist(err) {
|
||||||
|
err := os.MkdirAll(dirPath, 0777)
|
||||||
|
if err != nil {
|
||||||
|
log.WithError(err).Error("GetPostOrDeleteFile: Make nfs dir error")
|
||||||
|
}
|
||||||
|
}
|
||||||
err = c.SaveUploadedFile(file, filePath)
|
err = c.SaveUploadedFile(file, filePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.WithError(err).Error("GetPostOrDeleteFile: Save file error")
|
log.WithError(err).Error("GetPostOrDeleteFile: Save file error")
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue