This commit is contained in:
Daniel 2023-05-23 09:01:37 +08:00
parent 68a674b11e
commit e4229f2bad
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
6 changed files with 82 additions and 1 deletions

View file

@ -171,6 +171,36 @@ func readDir(c *gin.Context) {
ret.Data = files
}
func renameFile(c *gin.Context) {
ret := gulu.Ret.NewResult()
defer c.JSON(http.StatusOK, ret)
arg, ok := util.JsonArg(c, ret)
if !ok {
c.JSON(http.StatusOK, ret)
return
}
filePath := arg["path"].(string)
newPath := arg["newPath"].(string)
filePath = filepath.Join(util.WorkspaceDir, filePath)
_, err := os.Stat(filePath)
if os.IsNotExist(err) {
c.Status(404)
return
}
if nil != err {
logging.LogErrorf("stat [%s] failed: %s", filePath, err)
c.Status(500)
return
}
if err = filelock.Rename(filePath, newPath); nil != err {
c.Status(500)
return
}
}
func removeFile(c *gin.Context) {
ret := gulu.Ret.NewResult()
defer c.JSON(http.StatusOK, ret)