diff --git a/server/controllers/get.go b/server/controllers/down.go similarity index 59% rename from server/controllers/get.go rename to server/controllers/down.go index 67a9198c..3f2ac7fb 100644 --- a/server/controllers/get.go +++ b/server/controllers/down.go @@ -8,41 +8,6 @@ import ( "path/filepath" ) -// get request bean -type GetReq struct { - Path string `json:"path" binding:"required"` - Password string `json:"password"` -} - -// handle list request -func Get(c *gin.Context) { - var get GetReq - if err := c.ShouldBindJSON(&get); err != nil { - c.JSON(200, MetaResponse(400, "Bad Request:"+err.Error())) - return - } - log.Debugf("list:%+v", get) - dir, name := filepath.Split(get.Path) - file, err := models.GetFileByDirAndName(dir, name) - if err != nil { - if file == nil { - c.JSON(200, MetaResponse(404, "Path not found.")) - return - } - c.JSON(200, MetaResponse(500, err.Error())) - return - } - if file.Password != "" && file.Password != get.Password { - if get.Password == "" { - c.JSON(200, MetaResponse(401, "need password.")) - } else { - c.JSON(200, MetaResponse(401, "wrong password.")) - } - return - } - c.JSON(200, DataResponse(file)) -} - type DownReq struct { Password string `form:"pw"` } diff --git a/server/controllers/list.go b/server/controllers/list.go deleted file mode 100644 index 08ac97e8..00000000 --- a/server/controllers/list.go +++ /dev/null @@ -1,55 +0,0 @@ -package controllers - -import ( - "github.com/Xhofe/alist/server/models" - "github.com/gin-gonic/gin" - log "github.com/sirupsen/logrus" - "path/filepath" -) - -// list request bean -type ListReq struct { - Dir string `json:"dir" binding:"required"` - Password string `json:"password"` -} - -// handle list request -func List(c *gin.Context) { - var list ListReq - if err := c.ShouldBindJSON(&list); err != nil { - c.JSON(200, MetaResponse(400, "Bad Request:"+err.Error())) - return - } - log.Debugf("list:%+v", list) - // find folder model - dir, name := filepath.Split(list.Dir) - file, err := models.GetFileByDirAndName(dir, name) - if err != nil { - // folder model not exist - if file == nil { - c.JSON(200, MetaResponse(404, "folder not found.")) - return - } - c.JSON(200, MetaResponse(500, err.Error())) - return - } - // check password - if file.Password != "" && file.Password != list.Password { - if list.Password == "" { - c.JSON(200, MetaResponse(401, "need password.")) - } else { - c.JSON(200, MetaResponse(401, "wrong password.")) - } - return - } - files, err := models.GetFilesByDir(list.Dir + "/") - if err != nil { - c.JSON(200, MetaResponse(500, err.Error())) - return - } - // delete password - for i, _ := range *files { - (*files)[i].Password = "" - } - c.JSON(200, DataResponse(files)) -} diff --git a/server/router.go b/server/router.go index f1e37e6a..0391a0f3 100644 --- a/server/router.go +++ b/server/router.go @@ -24,8 +24,6 @@ func InitApiRouter(engine *gin.Engine) { apiV2 := engine.Group("/api") { apiV2.GET("/info", controllers.Info) - apiV2.POST("/list", controllers.List) - apiV2.POST("/get", controllers.Get) apiV2.POST("/path", controllers.Path) apiV2.POST("/office_preview", controllers.OfficePreview) apiV2.POST("/local_search", controllers.LocalSearch)