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)
|
||||
|
||||
build: export CGO_ENABLED=0
|
||||
|
|
|
|||
|
|
@ -16,10 +16,12 @@ func GetFiles(c *gin.Context) {
|
|||
dirPath := path.Join(config.NFSPath, username, appName)
|
||||
dir, err := os.ReadDir(dirPath)
|
||||
if err != nil {
|
||||
if !os.IsNotExist(err) {
|
||||
log.WithError(err).Error("Cannot ReadDir ", dirPath)
|
||||
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)})
|
||||
}
|
||||
|
||||
|
|
@ -27,6 +29,7 @@ func GetPostOrDeleteFile(c *gin.Context) {
|
|||
username := c.MustGet("username").(string)
|
||||
appName := c.Param("app")
|
||||
fileName := c.Param("filename")
|
||||
dirPath := path.Join(config.NFSPath, username, appName)
|
||||
filePath := path.Join(config.NFSPath, username, appName, fileName)
|
||||
if c.Request.Method == http.MethodGet {
|
||||
c.FileAttachment(filePath, fileName)
|
||||
|
|
@ -37,6 +40,12 @@ func GetPostOrDeleteFile(c *gin.Context) {
|
|||
c.JSON(http.StatusBadRequest, gin.H{"ok": false, "msg": err})
|
||||
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)
|
||||
if err != nil {
|
||||
log.WithError(err).Error("GetPostOrDeleteFile: Save file error")
|
||||
|
|
|
|||
Loading…
Reference in New Issue