mirror of https://github.com/Xhofe/alist
🎨 Improve the code structure
parent
7dfe48339c
commit
1779617cb9
3
alist.go
3
alist.go
|
@ -5,6 +5,7 @@ import (
|
|||
"fmt"
|
||||
"github.com/Xhofe/alist/bootstrap"
|
||||
"github.com/Xhofe/alist/conf"
|
||||
_ "github.com/Xhofe/alist/drivers"
|
||||
"github.com/Xhofe/alist/model"
|
||||
"github.com/Xhofe/alist/server"
|
||||
"github.com/gin-gonic/gin"
|
||||
|
@ -20,7 +21,7 @@ func init() {
|
|||
}
|
||||
|
||||
func Init() bool {
|
||||
bootstrap.InitLog()
|
||||
//bootstrap.InitLog()
|
||||
bootstrap.InitConf()
|
||||
bootstrap.InitCron()
|
||||
bootstrap.InitModel()
|
||||
|
|
|
@ -2,7 +2,7 @@ package bootstrap
|
|||
|
||||
import (
|
||||
"github.com/Xhofe/alist/conf"
|
||||
"github.com/Xhofe/alist/drivers"
|
||||
"github.com/Xhofe/alist/drivers/base"
|
||||
"github.com/Xhofe/alist/model"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
@ -15,7 +15,7 @@ func InitAccounts() {
|
|||
}
|
||||
for i, account := range accounts {
|
||||
model.RegisterAccount(account)
|
||||
driver, ok := drivers.GetDriver(account.Type)
|
||||
driver, ok := base.GetDriver(account.Type)
|
||||
if !ok {
|
||||
log.Errorf("no [%s] driver", account.Type)
|
||||
} else {
|
||||
|
|
|
@ -19,4 +19,8 @@ func InitLog() {
|
|||
FullTimestamp: true,
|
||||
})
|
||||
log.Infof("init log...")
|
||||
}
|
||||
|
||||
func init() {
|
||||
InitLog()
|
||||
}
|
|
@ -1,8 +1,9 @@
|
|||
package drivers
|
||||
package _23
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/Xhofe/alist/conf"
|
||||
"github.com/Xhofe/alist/drivers/base"
|
||||
"github.com/Xhofe/alist/model"
|
||||
"github.com/Xhofe/alist/utils"
|
||||
"github.com/go-resty/resty/v2"
|
||||
|
@ -52,7 +53,7 @@ func (driver Pan123) Login(account *model.Account) error {
|
|||
var resp Pan123TokenResp
|
||||
_, err := pan123Client.R().
|
||||
SetResult(&resp).
|
||||
SetBody(Json{
|
||||
SetBody(base.Json{
|
||||
"passport": account.Username,
|
||||
"password": account.Password,
|
||||
}).Post("https://www.123pan.com/api/user/sign_in")
|
||||
|
@ -135,14 +136,14 @@ func (driver Pan123) GetFile(path string, account *model.Account) (*Pan123File,
|
|||
if file.Type != conf.FOLDER {
|
||||
return &file, err
|
||||
} else {
|
||||
return nil, ErrNotFile
|
||||
return nil, base.ErrNotFile
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil, ErrPathNotFound
|
||||
return nil, base.ErrPathNotFound
|
||||
}
|
||||
|
||||
func init() {
|
||||
RegisterDriver(&Pan123{})
|
||||
base.RegisterDriver(&Pan123{})
|
||||
pan123Client.SetRetryCount(3)
|
||||
}
|
|
@ -1,8 +1,9 @@
|
|||
package drivers
|
||||
package _23
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/Xhofe/alist/conf"
|
||||
"github.com/Xhofe/alist/drivers/base"
|
||||
"github.com/Xhofe/alist/model"
|
||||
"github.com/Xhofe/alist/utils"
|
||||
"github.com/gin-gonic/gin"
|
||||
|
@ -13,46 +14,46 @@ import (
|
|||
|
||||
type Pan123 struct {}
|
||||
|
||||
func (driver Pan123) Config() DriverConfig {
|
||||
return DriverConfig{
|
||||
func (driver Pan123) Config() base.DriverConfig {
|
||||
return base.DriverConfig{
|
||||
Name: "123Pan",
|
||||
OnlyProxy: false,
|
||||
}
|
||||
}
|
||||
|
||||
func (driver Pan123) Items() []Item {
|
||||
return []Item{
|
||||
func (driver Pan123) Items() []base.Item {
|
||||
return []base.Item{
|
||||
{
|
||||
Name: "username",
|
||||
Label: "username",
|
||||
Type: TypeString,
|
||||
Type: base.TypeString,
|
||||
Required: true,
|
||||
Description: "account username/phone number",
|
||||
},
|
||||
{
|
||||
Name: "password",
|
||||
Label: "password",
|
||||
Type: TypeString,
|
||||
Type: base.TypeString,
|
||||
Required: true,
|
||||
Description: "account password",
|
||||
},
|
||||
{
|
||||
Name: "root_folder",
|
||||
Label: "root folder file_id",
|
||||
Type: TypeString,
|
||||
Type: base.TypeString,
|
||||
Required: false,
|
||||
},
|
||||
{
|
||||
Name: "order_by",
|
||||
Label: "order_by",
|
||||
Type: TypeSelect,
|
||||
Type: base.TypeSelect,
|
||||
Values: "name,fileId,updateAt,createAt",
|
||||
Required: true,
|
||||
},
|
||||
{
|
||||
Name: "order_direction",
|
||||
Label: "order_direction",
|
||||
Type: TypeSelect,
|
||||
Type: base.TypeSelect,
|
||||
Values: "asc,desc",
|
||||
Required: true,
|
||||
},
|
||||
|
@ -89,7 +90,7 @@ func (driver Pan123) File(path string, account *model.Account) (*model.File, err
|
|||
return &file, nil
|
||||
}
|
||||
}
|
||||
return nil, ErrPathNotFound
|
||||
return nil, base.ErrPathNotFound
|
||||
}
|
||||
|
||||
func (driver Pan123) Files(path string, account *model.Account) ([]model.File, error) {
|
||||
|
@ -125,7 +126,7 @@ func (driver Pan123) Link(path string, account *model.Account) (string, error) {
|
|||
}
|
||||
var resp Pan123DownResp
|
||||
_, err = pan123Client.R().SetResult(&resp).SetHeader("authorization", "Bearer "+account.AccessToken).
|
||||
SetBody(Json{
|
||||
SetBody(base.Json{
|
||||
"driveId": 0,
|
||||
"etag": file.Etag,
|
||||
"fileId": file.FileId,
|
||||
|
@ -152,7 +153,7 @@ func (driver Pan123) Link(path string, account *model.Account) (string, error) {
|
|||
return "", err
|
||||
}
|
||||
u_ := fmt.Sprintf("https://%s%s",u.Host,u.Path)
|
||||
res, err := NoRedirectClient.R().SetQueryParamsFromValues(u.Query()).Get(u_)
|
||||
res, err := base.NoRedirectClient.R().SetQueryParamsFromValues(u.Query()).Get(u_)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
@ -186,27 +187,27 @@ func (driver Pan123) Proxy(c *gin.Context, account *model.Account) {
|
|||
}
|
||||
|
||||
func (driver Pan123) Preview(path string, account *model.Account) (interface{}, error) {
|
||||
return nil, ErrNotSupport
|
||||
return nil, base.ErrNotSupport
|
||||
}
|
||||
|
||||
func (driver Pan123) MakeDir(path string, account *model.Account) error {
|
||||
return ErrNotImplement
|
||||
return base.ErrNotImplement
|
||||
}
|
||||
|
||||
func (driver Pan123) Move(src string, dst string, account *model.Account) error {
|
||||
return ErrNotImplement
|
||||
return base.ErrNotImplement
|
||||
}
|
||||
|
||||
func (driver Pan123) Copy(src string, dst string, account *model.Account) error {
|
||||
return ErrNotImplement
|
||||
return base.ErrNotImplement
|
||||
}
|
||||
|
||||
func (driver Pan123) Delete(path string, account *model.Account) error {
|
||||
return ErrNotImplement
|
||||
return base.ErrNotImplement
|
||||
}
|
||||
|
||||
func (driver Pan123) Upload(file *model.FileStream, account *model.Account) error {
|
||||
return ErrNotImplement
|
||||
return base.ErrNotImplement
|
||||
}
|
||||
|
||||
var _ Driver = (*Pan123)(nil)
|
||||
var _ base.Driver = (*Pan123)(nil)
|
|
@ -1,4 +1,4 @@
|
|||
package drivers
|
||||
package _89
|
||||
|
||||
import (
|
||||
"crypto/rand"
|
||||
|
@ -9,6 +9,7 @@ import (
|
|||
"encoding/pem"
|
||||
"fmt"
|
||||
"github.com/Xhofe/alist/conf"
|
||||
"github.com/Xhofe/alist/drivers/base"
|
||||
"github.com/Xhofe/alist/model"
|
||||
"github.com/Xhofe/alist/utils"
|
||||
"github.com/go-resty/resty/v2"
|
||||
|
@ -312,6 +313,6 @@ func b64tohex(a string) string {
|
|||
}
|
||||
|
||||
func init() {
|
||||
RegisterDriver(&Cloud189{})
|
||||
base.RegisterDriver(&Cloud189{})
|
||||
client189Map = make(map[string]*resty.Client, 0)
|
||||
}
|
|
@ -1,8 +1,9 @@
|
|||
package drivers
|
||||
package _89
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/Xhofe/alist/conf"
|
||||
"github.com/Xhofe/alist/drivers/base"
|
||||
"github.com/Xhofe/alist/model"
|
||||
"github.com/Xhofe/alist/utils"
|
||||
"github.com/gin-gonic/gin"
|
||||
|
@ -12,46 +13,46 @@ import (
|
|||
|
||||
type Cloud189 struct {}
|
||||
|
||||
func (driver Cloud189) Config() DriverConfig {
|
||||
return DriverConfig{
|
||||
func (driver Cloud189) Config() base.DriverConfig {
|
||||
return base.DriverConfig{
|
||||
Name: "189Cloud",
|
||||
OnlyProxy: false,
|
||||
}
|
||||
}
|
||||
|
||||
func (driver Cloud189) Items() []Item {
|
||||
return []Item{
|
||||
func (driver Cloud189) Items() []base.Item {
|
||||
return []base.Item{
|
||||
{
|
||||
Name: "username",
|
||||
Label: "username",
|
||||
Type: TypeString,
|
||||
Type: base.TypeString,
|
||||
Required: true,
|
||||
Description: "account username/phone number",
|
||||
},
|
||||
{
|
||||
Name: "password",
|
||||
Label: "password",
|
||||
Type: TypeString,
|
||||
Type: base.TypeString,
|
||||
Required: true,
|
||||
Description: "account password",
|
||||
},
|
||||
{
|
||||
Name: "root_folder",
|
||||
Label: "root folder file_id",
|
||||
Type: TypeString,
|
||||
Type: base.TypeString,
|
||||
Required: true,
|
||||
},
|
||||
{
|
||||
Name: "order_by",
|
||||
Label: "order_by",
|
||||
Type: TypeSelect,
|
||||
Type: base.TypeSelect,
|
||||
Values: "name,size,lastOpTime,createdDate",
|
||||
Required: true,
|
||||
},
|
||||
{
|
||||
Name: "order_direction",
|
||||
Label: "desc",
|
||||
Type: TypeSelect,
|
||||
Type: base.TypeSelect,
|
||||
Values: "true,false",
|
||||
Required: true,
|
||||
},
|
||||
|
@ -97,7 +98,7 @@ func (driver Cloud189) File(path string, account *model.Account) (*model.File, e
|
|||
return &file, nil
|
||||
}
|
||||
}
|
||||
return nil, ErrPathNotFound
|
||||
return nil, base.ErrPathNotFound
|
||||
}
|
||||
|
||||
func (driver Cloud189) Files(path string, account *model.Account) ([]model.File, error) {
|
||||
|
@ -132,7 +133,7 @@ func (driver Cloud189) Link(path string, account *model.Account) (string, error)
|
|||
return "", err
|
||||
}
|
||||
if file.Type == conf.FOLDER {
|
||||
return "", ErrNotFile
|
||||
return "", base.ErrNotFile
|
||||
}
|
||||
client, ok := client189Map[account.Name]
|
||||
if !ok {
|
||||
|
@ -161,7 +162,7 @@ func (driver Cloud189) Link(path string, account *model.Account) (string, error)
|
|||
if resp.ResCode != 0 {
|
||||
return "", fmt.Errorf(resp.ResMessage)
|
||||
}
|
||||
res, err := NoRedirectClient.R().Get(resp.FileDownloadUrl)
|
||||
res, err := base.NoRedirectClient.R().Get(resp.FileDownloadUrl)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
@ -194,28 +195,28 @@ func (driver Cloud189) Proxy(ctx *gin.Context, account *model.Account) {
|
|||
}
|
||||
|
||||
func (driver Cloud189) Preview(path string, account *model.Account) (interface{}, error) {
|
||||
return nil, ErrNotSupport
|
||||
return nil, base.ErrNotSupport
|
||||
}
|
||||
|
||||
|
||||
func (driver Cloud189) MakeDir(path string, account *model.Account) error {
|
||||
return ErrNotImplement
|
||||
return base.ErrNotImplement
|
||||
}
|
||||
|
||||
func (driver Cloud189) Move(src string, dst string, account *model.Account) error {
|
||||
return ErrNotImplement
|
||||
return base.ErrNotImplement
|
||||
}
|
||||
|
||||
func (driver Cloud189) Copy(src string, dst string, account *model.Account) error {
|
||||
return ErrNotImplement
|
||||
return base.ErrNotImplement
|
||||
}
|
||||
|
||||
func (driver Cloud189) Delete(path string, account *model.Account) error {
|
||||
return ErrNotImplement
|
||||
return base.ErrNotImplement
|
||||
}
|
||||
|
||||
func (driver Cloud189) Upload(file *model.FileStream, account *model.Account) error {
|
||||
return ErrNotImplement
|
||||
return base.ErrNotImplement
|
||||
}
|
||||
|
||||
var _ Driver = (*Cloud189)(nil)
|
||||
var _ base.Driver = (*Cloud189)(nil)
|
|
@ -1,8 +1,9 @@
|
|||
package drivers
|
||||
package alidrive
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/Xhofe/alist/conf"
|
||||
"github.com/Xhofe/alist/drivers/base"
|
||||
"github.com/Xhofe/alist/model"
|
||||
"github.com/Xhofe/alist/utils"
|
||||
"github.com/go-resty/resty/v2"
|
||||
|
@ -75,7 +76,7 @@ func (driver AliDrive) GetFiles(fileId string, account *model.Account) ([]AliFil
|
|||
SetResult(&resp).
|
||||
SetError(&e).
|
||||
SetHeader("authorization", "Bearer\t"+account.AccessToken).
|
||||
SetBody(Json{
|
||||
SetBody(base.Json{
|
||||
"drive_id": account.DriveId,
|
||||
"fields": "*",
|
||||
"image_thumbnail_process": "image/resize,w_400/format,jpeg",
|
||||
|
@ -127,16 +128,16 @@ func (driver AliDrive) GetFile(path string, account *model.Account) (*AliFile, e
|
|||
}
|
||||
}
|
||||
}
|
||||
return nil, ErrPathNotFound
|
||||
return nil, base.ErrPathNotFound
|
||||
}
|
||||
|
||||
func (driver AliDrive) RefreshToken(account *model.Account) error {
|
||||
url := "https://auth.aliyundrive.com/v2/account/token"
|
||||
var resp TokenResp
|
||||
var resp base.TokenResp
|
||||
var e AliRespError
|
||||
_, err := aliClient.R().
|
||||
//ForceContentType("application/json").
|
||||
SetBody(Json{"refresh_token": account.RefreshToken, "grant_type": "refresh_token"}).
|
||||
SetBody(base.Json{"refresh_token": account.RefreshToken, "grant_type": "refresh_token"}).
|
||||
SetResult(&resp).
|
||||
SetError(&e).
|
||||
Post(url)
|
||||
|
@ -156,7 +157,7 @@ func (driver AliDrive) RefreshToken(account *model.Account) error {
|
|||
}
|
||||
|
||||
func init() {
|
||||
RegisterDriver(&AliDrive{})
|
||||
base.RegisterDriver(&AliDrive{})
|
||||
aliClient.
|
||||
SetRetryCount(3).
|
||||
SetHeader("user-agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36").
|
|
@ -1,8 +1,9 @@
|
|||
package drivers
|
||||
package alidrive
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/Xhofe/alist/conf"
|
||||
"github.com/Xhofe/alist/drivers/base"
|
||||
"github.com/Xhofe/alist/model"
|
||||
"github.com/Xhofe/alist/utils"
|
||||
"github.com/gin-gonic/gin"
|
||||
|
@ -13,45 +14,45 @@ import (
|
|||
|
||||
type AliDrive struct{}
|
||||
|
||||
func (driver AliDrive) Config() DriverConfig {
|
||||
return DriverConfig{
|
||||
func (driver AliDrive) Config() base.DriverConfig {
|
||||
return base.DriverConfig{
|
||||
Name: "AliDrive",
|
||||
OnlyProxy: false,
|
||||
}
|
||||
}
|
||||
|
||||
func (driver AliDrive) Items() []Item {
|
||||
return []Item{
|
||||
func (driver AliDrive) Items() []base.Item {
|
||||
return []base.Item{
|
||||
{
|
||||
Name: "order_by",
|
||||
Label: "order_by",
|
||||
Type: TypeSelect,
|
||||
Values: "name,size,updated_at,created_at",
|
||||
Name: "order_by",
|
||||
Label: "order_by",
|
||||
Type: base.TypeSelect,
|
||||
Values: "name,size,updated_at,created_at",
|
||||
Required: false,
|
||||
},
|
||||
{
|
||||
Name: "order_direction",
|
||||
Label: "order_direction",
|
||||
Type: TypeSelect,
|
||||
Values: "ASC,DESC",
|
||||
Name: "order_direction",
|
||||
Label: "order_direction",
|
||||
Type: base.TypeSelect,
|
||||
Values: "ASC,DESC",
|
||||
Required: false,
|
||||
},
|
||||
{
|
||||
Name: "refresh_token",
|
||||
Label: "refresh token",
|
||||
Type: TypeString,
|
||||
Type: base.TypeString,
|
||||
Required: true,
|
||||
},
|
||||
{
|
||||
Name: "root_folder",
|
||||
Label: "root folder file_id",
|
||||
Type: TypeString,
|
||||
Type: base.TypeString,
|
||||
Required: false,
|
||||
},
|
||||
{
|
||||
Name: "limit",
|
||||
Label: "limit",
|
||||
Type: TypeNumber,
|
||||
Type: base.TypeNumber,
|
||||
Required: false,
|
||||
Description: ">0 and <=200",
|
||||
},
|
||||
|
@ -72,7 +73,7 @@ func (driver AliDrive) Save(account *model.Account, old *model.Account) error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
var resp Json
|
||||
var resp base.Json
|
||||
_, _ = aliClient.R().SetResult(&resp).
|
||||
SetBody("{}").
|
||||
SetHeader("authorization", "Bearer\t"+account.AccessToken).
|
||||
|
@ -123,7 +124,7 @@ func (driver AliDrive) File(path string, account *model.Account) (*model.File, e
|
|||
return &file, nil
|
||||
}
|
||||
}
|
||||
return nil, ErrPathNotFound
|
||||
return nil, base.ErrPathNotFound
|
||||
}
|
||||
|
||||
func (driver AliDrive) Files(path string, account *model.Account) ([]model.File, error) {
|
||||
|
@ -157,12 +158,12 @@ func (driver AliDrive) Link(path string, account *model.Account) (string, error)
|
|||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
var resp Json
|
||||
var resp base.Json
|
||||
var e AliRespError
|
||||
_, err = aliClient.R().SetResult(&resp).
|
||||
SetError(&e).
|
||||
SetHeader("authorization", "Bearer\t"+account.AccessToken).
|
||||
SetBody(Json{
|
||||
SetBody(base.Json{
|
||||
"drive_id": account.DriveId,
|
||||
"file_id": file.Id,
|
||||
"expire_sec": 14400,
|
||||
|
@ -214,10 +215,10 @@ func (driver AliDrive) Preview(path string, account *model.Account) (interface{}
|
|||
return nil, err
|
||||
}
|
||||
// office
|
||||
var resp Json
|
||||
var resp base.Json
|
||||
var e AliRespError
|
||||
var url string
|
||||
req := Json{
|
||||
req := base.Json{
|
||||
"drive_id": account.DriveId,
|
||||
"file_id": file.FileId,
|
||||
}
|
||||
|
@ -233,7 +234,7 @@ func (driver AliDrive) Preview(path string, account *model.Account) (interface{}
|
|||
req["category"] = "live_transcoding"
|
||||
}
|
||||
default:
|
||||
return nil, ErrNotSupport
|
||||
return nil, base.ErrNotSupport
|
||||
}
|
||||
_, err = aliClient.R().SetResult(&resp).SetError(&e).
|
||||
SetHeader("authorization", "Bearer\t"+account.AccessToken).
|
||||
|
@ -248,23 +249,23 @@ func (driver AliDrive) Preview(path string, account *model.Account) (interface{}
|
|||
}
|
||||
|
||||
func (driver AliDrive) MakeDir(path string, account *model.Account) error {
|
||||
return ErrNotImplement
|
||||
return base.ErrNotImplement
|
||||
}
|
||||
|
||||
func (driver AliDrive) Move(src string, dst string, account *model.Account) error {
|
||||
return ErrNotImplement
|
||||
return base.ErrNotImplement
|
||||
}
|
||||
|
||||
func (driver AliDrive) Copy(src string, dst string, account *model.Account) error {
|
||||
return ErrNotImplement
|
||||
return base.ErrNotImplement
|
||||
}
|
||||
|
||||
func (driver AliDrive) Delete(path string, account *model.Account) error {
|
||||
return ErrNotImplement
|
||||
return base.ErrNotImplement
|
||||
}
|
||||
|
||||
func (driver AliDrive) Upload(file *model.FileStream, account *model.Account) error {
|
||||
return ErrNotImplement
|
||||
return base.ErrNotImplement
|
||||
}
|
||||
|
||||
var _ Driver = (*AliDrive)(nil)
|
||||
var _ base.Driver = (*AliDrive)(nil)
|
|
@ -0,0 +1,11 @@
|
|||
package drivers
|
||||
|
||||
import (
|
||||
_ "github.com/Xhofe/alist/drivers/123"
|
||||
_ "github.com/Xhofe/alist/drivers/189"
|
||||
_ "github.com/Xhofe/alist/drivers/alidrive"
|
||||
_ "github.com/Xhofe/alist/drivers/google"
|
||||
_ "github.com/Xhofe/alist/drivers/lanzou"
|
||||
_ "github.com/Xhofe/alist/drivers/native"
|
||||
_ "github.com/Xhofe/alist/drivers/onedrive"
|
||||
)
|
|
@ -1,9 +1,10 @@
|
|||
package drivers
|
||||
package base
|
||||
|
||||
import (
|
||||
"github.com/Xhofe/alist/model"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/go-resty/resty/v2"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
|
@ -48,7 +49,7 @@ type TokenResp struct {
|
|||
var driversMap = map[string]Driver{}
|
||||
|
||||
func RegisterDriver(driver Driver) {
|
||||
//log.Infof("register driver: [%s]", driver.Config().Name)
|
||||
log.Infof("register driver: [%s]", driver.Config().Name)
|
||||
driversMap[driver.Config().Name] = driver
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package drivers
|
||||
package base
|
||||
|
||||
import "fmt"
|
||||
|
|
@ -1,8 +1,9 @@
|
|||
package drivers
|
||||
package google
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/Xhofe/alist/conf"
|
||||
"github.com/Xhofe/alist/drivers/base"
|
||||
"github.com/Xhofe/alist/model"
|
||||
"github.com/Xhofe/alist/utils"
|
||||
"github.com/gin-gonic/gin"
|
||||
|
@ -12,37 +13,37 @@ import (
|
|||
|
||||
type GoogleDrive struct{}
|
||||
|
||||
func (driver GoogleDrive) Config() DriverConfig {
|
||||
return DriverConfig{
|
||||
func (driver GoogleDrive) Config() base.DriverConfig {
|
||||
return base.DriverConfig{
|
||||
Name: "GoogleDrive",
|
||||
OnlyProxy: true,
|
||||
}
|
||||
}
|
||||
|
||||
func (driver GoogleDrive) Items() []Item {
|
||||
return []Item{
|
||||
func (driver GoogleDrive) Items() []base.Item {
|
||||
return []base.Item{
|
||||
{
|
||||
Name: "client_id",
|
||||
Label: "client id",
|
||||
Type: TypeString,
|
||||
Type: base.TypeString,
|
||||
Required: true,
|
||||
},
|
||||
{
|
||||
Name: "client_secret",
|
||||
Label: "client secret",
|
||||
Type: TypeString,
|
||||
Type: base.TypeString,
|
||||
Required: true,
|
||||
},
|
||||
{
|
||||
Name: "refresh_token",
|
||||
Label: "refresh token",
|
||||
Type: TypeString,
|
||||
Type: base.TypeString,
|
||||
Required: true,
|
||||
},
|
||||
{
|
||||
Name: "root_folder",
|
||||
Label: "root folder file_id",
|
||||
Type: TypeString,
|
||||
Type: base.TypeString,
|
||||
Required: false,
|
||||
},
|
||||
}
|
||||
|
@ -86,7 +87,7 @@ func (driver GoogleDrive) File(path string, account *model.Account) (*model.File
|
|||
return &file, nil
|
||||
}
|
||||
}
|
||||
return nil, ErrPathNotFound
|
||||
return nil, base.ErrPathNotFound
|
||||
}
|
||||
|
||||
func (driver GoogleDrive) Files(path string, account *model.Account) ([]model.File, error) {
|
||||
|
@ -121,7 +122,7 @@ func (driver GoogleDrive) Link(path string, account *model.Account) (string, err
|
|||
return "", err
|
||||
}
|
||||
if file.Type == conf.FOLDER {
|
||||
return "", ErrNotFile
|
||||
return "", base.ErrNotFile
|
||||
}
|
||||
link := fmt.Sprintf("https://www.googleapis.com/drive/v3/files/%s?includeItemsFromAllDrives=true&supportsAllDrives=true", file.Id)
|
||||
var e GoogleError
|
||||
|
@ -165,27 +166,27 @@ func (driver GoogleDrive) Proxy(c *gin.Context, account *model.Account) {
|
|||
}
|
||||
|
||||
func (driver GoogleDrive) Preview(path string, account *model.Account) (interface{}, error) {
|
||||
return nil, ErrNotSupport
|
||||
return nil, base.ErrNotSupport
|
||||
}
|
||||
|
||||
func (driver GoogleDrive) MakeDir(path string, account *model.Account) error {
|
||||
return ErrNotImplement
|
||||
return base.ErrNotImplement
|
||||
}
|
||||
|
||||
func (driver GoogleDrive) Move(src string, dst string, account *model.Account) error {
|
||||
return ErrNotImplement
|
||||
return base.ErrNotImplement
|
||||
}
|
||||
|
||||
func (driver GoogleDrive) Copy(src string, dst string, account *model.Account) error {
|
||||
return ErrNotImplement
|
||||
return base.ErrNotImplement
|
||||
}
|
||||
|
||||
func (driver GoogleDrive) Delete(path string, account *model.Account) error {
|
||||
return ErrNotImplement
|
||||
return base.ErrNotImplement
|
||||
}
|
||||
|
||||
func (driver GoogleDrive) Upload(file *model.FileStream, account *model.Account) error {
|
||||
return ErrNotImplement
|
||||
return base.ErrNotImplement
|
||||
}
|
||||
|
||||
var _ Driver = (*GoogleDrive)(nil)
|
||||
var _ base.Driver = (*GoogleDrive)(nil)
|
|
@ -1,8 +1,9 @@
|
|||
package drivers
|
||||
package google
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/Xhofe/alist/conf"
|
||||
"github.com/Xhofe/alist/drivers/base"
|
||||
"github.com/Xhofe/alist/model"
|
||||
"github.com/Xhofe/alist/utils"
|
||||
"github.com/go-resty/resty/v2"
|
||||
|
@ -20,7 +21,7 @@ type GoogleTokenError struct {
|
|||
|
||||
func (driver GoogleDrive) RefreshToken(account *model.Account) error {
|
||||
url := "https://www.googleapis.com/oauth2/v4/token"
|
||||
var resp TokenResp
|
||||
var resp base.TokenResp
|
||||
var e GoogleTokenError
|
||||
_, err := googleClient.R().SetResult(&resp).SetError(&e).
|
||||
SetFormData(map[string]string{
|
||||
|
@ -152,6 +153,6 @@ func (driver GoogleDrive) GetFiles(id string, account *model.Account) ([]GoogleF
|
|||
//}
|
||||
|
||||
func init() {
|
||||
RegisterDriver(&GoogleDrive{})
|
||||
base.RegisterDriver(&GoogleDrive{})
|
||||
googleClient.SetRetryCount(3)
|
||||
}
|
|
@ -1,8 +1,9 @@
|
|||
package drivers
|
||||
package lanzou
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/Xhofe/alist/conf"
|
||||
"github.com/Xhofe/alist/drivers/base"
|
||||
"github.com/Xhofe/alist/model"
|
||||
"github.com/Xhofe/alist/utils"
|
||||
"github.com/gin-gonic/gin"
|
||||
|
@ -12,42 +13,42 @@ import (
|
|||
|
||||
type Lanzou struct{}
|
||||
|
||||
func (driver Lanzou) Config() DriverConfig {
|
||||
return DriverConfig{
|
||||
func (driver Lanzou) Config() base.DriverConfig {
|
||||
return base.DriverConfig{
|
||||
Name: "Lanzou",
|
||||
OnlyProxy: false,
|
||||
}
|
||||
}
|
||||
|
||||
func (driver Lanzou) Items() []Item {
|
||||
return []Item{
|
||||
func (driver Lanzou) Items() []base.Item {
|
||||
return []base.Item{
|
||||
{
|
||||
Name: "onedrive_type",
|
||||
Label: "lanzou type",
|
||||
Type: TypeSelect,
|
||||
Type: base.TypeSelect,
|
||||
Required: true,
|
||||
Values: "cookie,url",
|
||||
},
|
||||
{
|
||||
Name: "access_token",
|
||||
Label: "cookie",
|
||||
Type: TypeString,
|
||||
Type: base.TypeString,
|
||||
Description: "about 15 days valid",
|
||||
},
|
||||
{
|
||||
Name: "root_folder",
|
||||
Label: "root folder file_id",
|
||||
Type: TypeString,
|
||||
Type: base.TypeString,
|
||||
},
|
||||
{
|
||||
Name: "site_url",
|
||||
Label: "share url",
|
||||
Type: TypeString,
|
||||
Type: base.TypeString,
|
||||
},
|
||||
{
|
||||
Name: "password",
|
||||
Label: "share password",
|
||||
Type: TypeString,
|
||||
Type: base.TypeString,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -85,7 +86,7 @@ func (driver Lanzou) File(path string, account *model.Account) (*model.File, err
|
|||
return &file, nil
|
||||
}
|
||||
}
|
||||
return nil, ErrPathNotFound
|
||||
return nil, base.ErrPathNotFound
|
||||
}
|
||||
|
||||
func (driver Lanzou) Files(path string, account *model.Account) ([]model.File, error) {
|
||||
|
@ -157,27 +158,27 @@ func (driver Lanzou) Proxy(c *gin.Context, account *model.Account) {
|
|||
}
|
||||
|
||||
func (driver Lanzou) Preview(path string, account *model.Account) (interface{}, error) {
|
||||
return nil, ErrNotSupport
|
||||
return nil, base.ErrNotSupport
|
||||
}
|
||||
|
||||
func (driver *Lanzou) MakeDir(path string, account *model.Account) error {
|
||||
return ErrNotImplement
|
||||
return base.ErrNotImplement
|
||||
}
|
||||
|
||||
func (driver *Lanzou) Move(src string, dst string, account *model.Account) error {
|
||||
return ErrNotImplement
|
||||
return base.ErrNotImplement
|
||||
}
|
||||
|
||||
func (driver *Lanzou) Copy(src string, dst string, account *model.Account) error {
|
||||
return ErrNotImplement
|
||||
return base.ErrNotImplement
|
||||
}
|
||||
|
||||
func (driver *Lanzou) Delete(path string, account *model.Account) error {
|
||||
return ErrNotImplement
|
||||
return base.ErrNotImplement
|
||||
}
|
||||
|
||||
func (driver *Lanzou) Upload(file *model.FileStream, account *model.Account) error {
|
||||
return ErrNotImplement
|
||||
return base.ErrNotImplement
|
||||
}
|
||||
|
||||
var _ Driver = (*Lanzou)(nil)
|
||||
var _ base.Driver = (*Lanzou)(nil)
|
|
@ -1,8 +1,9 @@
|
|||
package drivers
|
||||
package lanzou
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/Xhofe/alist/conf"
|
||||
"github.com/Xhofe/alist/drivers/base"
|
||||
"github.com/Xhofe/alist/model"
|
||||
"github.com/Xhofe/alist/utils"
|
||||
"github.com/go-resty/resty/v2"
|
||||
|
@ -231,7 +232,7 @@ func (driver *Lanzou) GetLink(downId string) (string, error) {
|
|||
}
|
||||
|
||||
func init() {
|
||||
RegisterDriver(&Lanzou{})
|
||||
base.RegisterDriver(&Lanzou{})
|
||||
lanzouClient.
|
||||
SetRetryCount(3).
|
||||
SetHeader("user-agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36")
|
|
@ -1,8 +1,9 @@
|
|||
package drivers
|
||||
package native
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/Xhofe/alist/conf"
|
||||
"github.com/Xhofe/alist/drivers/base"
|
||||
"github.com/Xhofe/alist/model"
|
||||
"github.com/Xhofe/alist/utils"
|
||||
"github.com/gin-gonic/gin"
|
||||
|
@ -16,32 +17,32 @@ import (
|
|||
|
||||
type Native struct{}
|
||||
|
||||
func (driver Native) Config() DriverConfig {
|
||||
return DriverConfig{
|
||||
func (driver Native) Config() base.DriverConfig {
|
||||
return base.DriverConfig{
|
||||
Name: "Native",
|
||||
OnlyProxy: true,
|
||||
}
|
||||
}
|
||||
|
||||
func (driver Native) Items() []Item {
|
||||
return []Item{
|
||||
func (driver Native) Items() []base.Item {
|
||||
return []base.Item{
|
||||
{
|
||||
Name: "root_folder",
|
||||
Label: "root folder path",
|
||||
Type: TypeString,
|
||||
Type: base.TypeString,
|
||||
Required: true,
|
||||
},
|
||||
{
|
||||
Name: "order_by",
|
||||
Label: "order_by",
|
||||
Type: TypeSelect,
|
||||
Type: base.TypeSelect,
|
||||
Values: "name,size,updated_at",
|
||||
Required: false,
|
||||
},
|
||||
{
|
||||
Name: "order_direction",
|
||||
Label: "order_direction",
|
||||
Type: TypeSelect,
|
||||
Type: base.TypeSelect,
|
||||
Values: "ASC,DESC",
|
||||
Required: false,
|
||||
},
|
||||
|
@ -67,7 +68,7 @@ func (driver Native) Save(account *model.Account, old *model.Account) error {
|
|||
func (driver Native) File(path string, account *model.Account) (*model.File, error) {
|
||||
fullPath := filepath.Join(account.RootFolder, path)
|
||||
if !utils.Exists(fullPath) {
|
||||
return nil, ErrPathNotFound
|
||||
return nil, base.ErrPathNotFound
|
||||
}
|
||||
f, err := os.Stat(fullPath)
|
||||
if err != nil {
|
||||
|
@ -91,7 +92,7 @@ func (driver Native) File(path string, account *model.Account) (*model.File, err
|
|||
func (driver Native) Files(path string, account *model.Account) ([]model.File, error) {
|
||||
fullPath := filepath.Join(account.RootFolder, path)
|
||||
if !utils.Exists(fullPath) {
|
||||
return nil, ErrPathNotFound
|
||||
return nil, base.ErrPathNotFound
|
||||
}
|
||||
files := make([]model.File, 0)
|
||||
rawFiles, err := ioutil.ReadDir(fullPath)
|
||||
|
@ -156,7 +157,7 @@ func (driver Native) Proxy(c *gin.Context, account *model.Account) {
|
|||
}
|
||||
|
||||
func (driver Native) Preview(path string, account *model.Account) (interface{}, error) {
|
||||
return nil, ErrNotSupport
|
||||
return nil, base.ErrNotSupport
|
||||
}
|
||||
|
||||
func (driver Native) MakeDir(path string, account *model.Account) error {
|
||||
|
@ -181,7 +182,7 @@ func (driver Native) Copy(src string, dst string, account *model.Account) error
|
|||
dstFile, err := driver.File(dst, account)
|
||||
if err == nil {
|
||||
if !dstFile.IsDir() {
|
||||
return ErrNotSupport
|
||||
return base.ErrNotSupport
|
||||
}
|
||||
}
|
||||
if srcFile.IsDir() {
|
||||
|
@ -226,4 +227,4 @@ func (driver Native) Upload(file *model.FileStream, account *model.Account) erro
|
|||
return err
|
||||
}
|
||||
|
||||
var _ Driver = (*Native)(nil)
|
||||
var _ base.Driver = (*Native)(nil)
|
|
@ -1,7 +1,8 @@
|
|||
package drivers
|
||||
package native
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/Xhofe/alist/drivers/base"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
|
@ -69,5 +70,5 @@ func (driver *Native) CopyDir(src string, dst string) error {
|
|||
}
|
||||
|
||||
func init() {
|
||||
RegisterDriver(&Native{})
|
||||
base.RegisterDriver(&Native{})
|
||||
}
|
|
@ -1,8 +1,9 @@
|
|||
package drivers
|
||||
package onedrive
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/Xhofe/alist/conf"
|
||||
"github.com/Xhofe/alist/drivers/base"
|
||||
"github.com/Xhofe/alist/model"
|
||||
"github.com/Xhofe/alist/utils"
|
||||
"github.com/gin-gonic/gin"
|
||||
|
@ -14,19 +15,19 @@ import (
|
|||
type Onedrive struct{}
|
||||
|
||||
|
||||
func (driver Onedrive) Config() DriverConfig {
|
||||
return DriverConfig{
|
||||
func (driver Onedrive) Config() base.DriverConfig {
|
||||
return base.DriverConfig{
|
||||
Name: "Onedrive",
|
||||
OnlyProxy: false,
|
||||
}
|
||||
}
|
||||
|
||||
func (driver Onedrive) Items() []Item {
|
||||
return []Item{
|
||||
func (driver Onedrive) Items() []base.Item {
|
||||
return []base.Item{
|
||||
{
|
||||
Name: "zone",
|
||||
Label: "zone",
|
||||
Type: TypeSelect,
|
||||
Type: base.TypeSelect,
|
||||
Required: true,
|
||||
Values: "global,cn,us,de",
|
||||
Description: "",
|
||||
|
@ -34,57 +35,57 @@ func (driver Onedrive) Items() []Item {
|
|||
{
|
||||
Name: "onedrive_type",
|
||||
Label: "onedrive type",
|
||||
Type: TypeSelect,
|
||||
Type: base.TypeSelect,
|
||||
Required: true,
|
||||
Values: "onedrive,sharepoint",
|
||||
},
|
||||
{
|
||||
Name: "client_id",
|
||||
Label: "client id",
|
||||
Type: TypeString,
|
||||
Type: base.TypeString,
|
||||
Required: true,
|
||||
},
|
||||
{
|
||||
Name: "client_secret",
|
||||
Label: "client secret",
|
||||
Type: TypeString,
|
||||
Type: base.TypeString,
|
||||
Required: true,
|
||||
},
|
||||
{
|
||||
Name: "redirect_uri",
|
||||
Label: "redirect uri",
|
||||
Type: TypeString,
|
||||
Type: base.TypeString,
|
||||
Required: true,
|
||||
},
|
||||
{
|
||||
Name: "refresh_token",
|
||||
Label: "refresh token",
|
||||
Type: TypeString,
|
||||
Type: base.TypeString,
|
||||
Required: true,
|
||||
},
|
||||
{
|
||||
Name: "site_id",
|
||||
Label: "site id",
|
||||
Type: TypeString,
|
||||
Type: base.TypeString,
|
||||
Required: false,
|
||||
},
|
||||
{
|
||||
Name: "root_folder",
|
||||
Label: "root folder path",
|
||||
Type: TypeString,
|
||||
Type: base.TypeString,
|
||||
Required: false,
|
||||
},
|
||||
{
|
||||
Name: "order_by",
|
||||
Label: "order_by",
|
||||
Type: TypeSelect,
|
||||
Type: base.TypeSelect,
|
||||
Values: "name,size,lastModifiedDateTime",
|
||||
Required: false,
|
||||
},
|
||||
{
|
||||
Name: "order_direction",
|
||||
Label: "order_direction",
|
||||
Type: TypeSelect,
|
||||
Type: base.TypeSelect,
|
||||
Values: "asc,desc",
|
||||
Required: false,
|
||||
},
|
||||
|
@ -148,7 +149,7 @@ func (driver Onedrive) File(path string, account *model.Account) (*model.File, e
|
|||
return &file, nil
|
||||
}
|
||||
}
|
||||
return nil, ErrPathNotFound
|
||||
return nil, base.ErrPathNotFound
|
||||
}
|
||||
|
||||
func (driver Onedrive) Files(path string, account *model.Account) ([]model.File, error) {
|
||||
|
@ -205,27 +206,27 @@ func (driver Onedrive) Proxy(c *gin.Context, account *model.Account) {
|
|||
}
|
||||
|
||||
func (driver Onedrive) Preview(path string, account *model.Account) (interface{}, error) {
|
||||
return nil, ErrNotSupport
|
||||
return nil, base.ErrNotSupport
|
||||
}
|
||||
|
||||
func (driver Onedrive) MakeDir(path string, account *model.Account) error {
|
||||
return ErrNotImplement
|
||||
return base.ErrNotImplement
|
||||
}
|
||||
|
||||
func (driver Onedrive) Move(src string, dst string, account *model.Account) error {
|
||||
return ErrNotImplement
|
||||
return base.ErrNotImplement
|
||||
}
|
||||
|
||||
func (driver Onedrive) Copy(src string, dst string, account *model.Account) error {
|
||||
return ErrNotImplement
|
||||
return base.ErrNotImplement
|
||||
}
|
||||
|
||||
func (driver Onedrive) Delete(path string, account *model.Account) error {
|
||||
return ErrNotImplement
|
||||
return base.ErrNotImplement
|
||||
}
|
||||
|
||||
func (driver Onedrive) Upload(file *model.FileStream, account *model.Account) error {
|
||||
return ErrNotImplement
|
||||
return base.ErrNotImplement
|
||||
}
|
||||
|
||||
var _ Driver = (*Onedrive)(nil)
|
||||
var _ base.Driver = (*Onedrive)(nil)
|
|
@ -1,8 +1,9 @@
|
|||
package drivers
|
||||
package onedrive
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/Xhofe/alist/conf"
|
||||
"github.com/Xhofe/alist/drivers/base"
|
||||
"github.com/Xhofe/alist/model"
|
||||
"github.com/Xhofe/alist/utils"
|
||||
"github.com/go-resty/resty/v2"
|
||||
|
@ -73,7 +74,7 @@ type OneTokenErr struct {
|
|||
|
||||
func (driver Onedrive) RefreshToken(account *model.Account) error {
|
||||
url := driver.GetMetaUrl(account, true, "") + "/common/oauth2/v2.0/token"
|
||||
var resp TokenResp
|
||||
var resp base.TokenResp
|
||||
var e OneTokenErr
|
||||
_, err := oneClient.R().SetResult(&resp).SetError(&e).SetFormData(map[string]string{
|
||||
"grant_type": "refresh_token",
|
||||
|
@ -185,6 +186,6 @@ func (driver Onedrive) GetFile(account *model.Account, path string) (*OneFile, e
|
|||
}
|
||||
|
||||
func init() {
|
||||
RegisterDriver(&Onedrive{})
|
||||
base.RegisterDriver(&Onedrive{})
|
||||
oneClient.SetRetryCount(3)
|
||||
}
|
|
@ -2,7 +2,7 @@ package server
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/Xhofe/alist/drivers"
|
||||
"github.com/Xhofe/alist/drivers/base"
|
||||
"github.com/Xhofe/alist/model"
|
||||
"github.com/gin-gonic/gin"
|
||||
log "github.com/sirupsen/logrus"
|
||||
|
@ -25,7 +25,7 @@ func CreateAccount(c *gin.Context) {
|
|||
ErrorResp(c, err, 400)
|
||||
return
|
||||
}
|
||||
driver, ok := drivers.GetDriver(req.Type)
|
||||
driver, ok := base.GetDriver(req.Type)
|
||||
if !ok {
|
||||
ErrorResp(c, fmt.Errorf("no [%s] driver", req.Type), 400)
|
||||
return
|
||||
|
@ -51,7 +51,7 @@ func SaveAccount(c *gin.Context) {
|
|||
ErrorResp(c, err, 400)
|
||||
return
|
||||
}
|
||||
driver, ok := drivers.GetDriver(req.Type)
|
||||
driver, ok := base.GetDriver(req.Type)
|
||||
if !ok {
|
||||
ErrorResp(c, fmt.Errorf("no [%s] driver", req.Type), 400)
|
||||
return
|
||||
|
|
|
@ -2,7 +2,7 @@ package server
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/Xhofe/alist/drivers"
|
||||
"github.com/Xhofe/alist/drivers/base"
|
||||
"github.com/Xhofe/alist/model"
|
||||
"github.com/gin-gonic/gin"
|
||||
log "github.com/sirupsen/logrus"
|
||||
|
@ -15,7 +15,7 @@ type Resp struct {
|
|||
Data interface{} `json:"data"`
|
||||
}
|
||||
|
||||
func ParsePath(rawPath string) (*model.Account, string, drivers.Driver, error) {
|
||||
func ParsePath(rawPath string) (*model.Account, string, base.Driver, error) {
|
||||
var path, name string
|
||||
switch model.AccountsCount() {
|
||||
case 0:
|
||||
|
@ -32,7 +32,7 @@ func ParsePath(rawPath string) (*model.Account, string, drivers.Driver, error) {
|
|||
if !ok {
|
||||
return nil, "", nil, fmt.Errorf("no [%s] account", name)
|
||||
}
|
||||
driver, ok := drivers.GetDriver(account.Type)
|
||||
driver, ok := base.GetDriver(account.Type)
|
||||
if !ok {
|
||||
return nil, "", nil, fmt.Errorf("no [%s] driver", account.Type)
|
||||
}
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
package server
|
||||
|
||||
import (
|
||||
"github.com/Xhofe/alist/drivers"
|
||||
"github.com/Xhofe/alist/drivers/base"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func GetDrivers(c *gin.Context) {
|
||||
SuccessResp(c, drivers.GetDrivers())
|
||||
SuccessResp(c, base.GetDrivers())
|
||||
}
|
|
@ -8,7 +8,7 @@ import (
|
|||
"context"
|
||||
"fmt"
|
||||
"github.com/Xhofe/alist/conf"
|
||||
"github.com/Xhofe/alist/drivers"
|
||||
"github.com/Xhofe/alist/drivers/base"
|
||||
"github.com/Xhofe/alist/model"
|
||||
"github.com/Xhofe/alist/utils"
|
||||
log "github.com/sirupsen/logrus"
|
||||
|
@ -22,7 +22,7 @@ import (
|
|||
|
||||
type FileSystem struct{}
|
||||
|
||||
func ParsePath(rawPath string) (*model.Account, string, drivers.Driver, error) {
|
||||
func ParsePath(rawPath string) (*model.Account, string, base.Driver, error) {
|
||||
var path, name string
|
||||
switch model.AccountsCount() {
|
||||
case 0:
|
||||
|
@ -39,7 +39,7 @@ func ParsePath(rawPath string) (*model.Account, string, drivers.Driver, error) {
|
|||
if !ok {
|
||||
return nil, "", nil, fmt.Errorf("no [%s] account", name)
|
||||
}
|
||||
driver, ok := drivers.GetDriver(account.Type)
|
||||
driver, ok := base.GetDriver(account.Type)
|
||||
if !ok {
|
||||
return nil, "", nil, fmt.Errorf("no [%s] driver", account.Type)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue