🎇 多盘支持
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
||||
"github.com/gin-gonic/gin"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type DownReq struct {
|
||||
@@ -44,7 +45,12 @@ func Down(c *gin.Context) {
|
||||
c.JSON(200, MetaResponse(406, "无法下载目录."))
|
||||
return
|
||||
}
|
||||
file, err := alidrive.GetDownLoadUrl(fileModel.FileId)
|
||||
drive := utils.GetDriveByName(strings.Split(dir,"/")[0])
|
||||
if drive == nil {
|
||||
c.JSON(200, MetaResponse(500, "找不到drive."))
|
||||
return
|
||||
}
|
||||
file, err := alidrive.GetDownLoadUrl(fileModel.FileId, drive)
|
||||
if err != nil {
|
||||
c.JSON(200, MetaResponse(500, err.Error()))
|
||||
return
|
||||
|
@@ -3,9 +3,11 @@ package controllers
|
||||
import (
|
||||
"github.com/Xhofe/alist/alidrive"
|
||||
"github.com/Xhofe/alist/server/models"
|
||||
"github.com/Xhofe/alist/utils"
|
||||
"github.com/gin-gonic/gin"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// get request bean
|
||||
@@ -40,7 +42,12 @@ func Get(c *gin.Context) {
|
||||
}
|
||||
return
|
||||
}
|
||||
down, err := alidrive.GetDownLoadUrl(file.FileId)
|
||||
drive := utils.GetDriveByName(strings.Split(dir,"/")[0])
|
||||
if drive == nil {
|
||||
c.JSON(200, MetaResponse(500, "找不到drive."))
|
||||
return
|
||||
}
|
||||
down, err := alidrive.GetDownLoadUrl(file.FileId, drive)
|
||||
if err != nil {
|
||||
c.JSON(200, MetaResponse(500, err.Error()))
|
||||
return
|
||||
|
@@ -2,6 +2,7 @@ package controllers
|
||||
|
||||
import (
|
||||
"github.com/Xhofe/alist/alidrive"
|
||||
"github.com/Xhofe/alist/utils"
|
||||
"github.com/gin-gonic/gin"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
@@ -12,13 +13,18 @@ type OfficePreviewReq struct {
|
||||
|
||||
// handle office_preview request
|
||||
func OfficePreview(c *gin.Context) {
|
||||
drive := utils.GetDriveByName(c.Param("drive"))
|
||||
if drive == nil {
|
||||
c.JSON(200, MetaResponse(400, "drive isn't exist."))
|
||||
return
|
||||
}
|
||||
var req OfficePreviewReq
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
c.JSON(200, MetaResponse(400, "Bad Request:"+err.Error()))
|
||||
return
|
||||
}
|
||||
log.Debugf("preview_req:%+v", req)
|
||||
preview, err := alidrive.GetOfficePreviewUrl(req.FileId)
|
||||
preview, err := alidrive.GetOfficePreviewUrl(req.FileId, drive)
|
||||
if err != nil {
|
||||
c.JSON(200, MetaResponse(500, err.Error()))
|
||||
return
|
||||
|
@@ -55,7 +55,11 @@ func Path(c *gin.Context) {
|
||||
}
|
||||
// delete password
|
||||
for i, _ := range *files {
|
||||
(*files)[i].Password = ""
|
||||
if (*files)[i].Password == "" {
|
||||
(*files)[i].Password = "n"
|
||||
}else {
|
||||
(*files)[i].Password = "y"
|
||||
}
|
||||
}
|
||||
c.JSON(200, DataResponse(files))
|
||||
}
|
||||
|
@@ -3,6 +3,7 @@ package controllers
|
||||
import (
|
||||
"github.com/Xhofe/alist/conf"
|
||||
"github.com/Xhofe/alist/server/models"
|
||||
"github.com/Xhofe/alist/utils"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
@@ -13,7 +14,12 @@ func Info(c *gin.Context) {
|
||||
|
||||
// rebuild tree
|
||||
func RebuildTree(c *gin.Context) {
|
||||
password := c.Param("password")[1:]
|
||||
drive := utils.GetDriveByName(c.Param("drive"))
|
||||
if drive == nil {
|
||||
c.JSON(200, MetaResponse(400, "drive isn't exist."))
|
||||
return
|
||||
}
|
||||
password := c.Param("password")
|
||||
if password != conf.Conf.Server.Password {
|
||||
if password == "" {
|
||||
c.JSON(200, MetaResponse(401, "need password."))
|
||||
@@ -22,11 +28,11 @@ func RebuildTree(c *gin.Context) {
|
||||
c.JSON(200, MetaResponse(401, "wrong password."))
|
||||
return
|
||||
}
|
||||
if err := models.Clear(); err != nil {
|
||||
if err := models.Clear(drive); err != nil {
|
||||
c.JSON(200, MetaResponse(500, err.Error()))
|
||||
return
|
||||
}
|
||||
if err := models.BuildTree(); err != nil {
|
||||
if err := models.BuildTree(drive); err != nil {
|
||||
c.JSON(200, MetaResponse(500, err.Error()))
|
||||
return
|
||||
}
|
||||
|
Reference in New Issue
Block a user