mirror of https://github.com/Xhofe/alist
chore!: change root folder
parent
a4a8739748
commit
a1c86b3350
|
@ -10,7 +10,7 @@ type Addition struct {
|
|||
Password string `json:"password" required:"true"`
|
||||
OrderBy string `json:"order_by" type:"select" options:"name,fileId,updateAt,createAt" default:"name"`
|
||||
OrderDirection string `json:"order_direction" type:"select" options:"asc,desc" default:"asc"`
|
||||
driver.RootFolderID
|
||||
driver.RootID
|
||||
// define other
|
||||
StreamUpload bool `json:"stream_upload"`
|
||||
//Field string `json:"field" type:"select" required:"true" options:"a,b,c" default:"a"`
|
||||
|
|
|
@ -6,7 +6,7 @@ import (
|
|||
)
|
||||
|
||||
type Addition struct {
|
||||
driver.RootFolderID
|
||||
driver.RootID
|
||||
RefreshToken string `json:"refresh_token" required:"true"`
|
||||
OrderBy string `json:"order_by" type:"select" options:"name,size,updated_at,created_at"`
|
||||
OrderDirection string `json:"order_direction" type:"select" options:"ASC,DESC"`
|
||||
|
|
|
@ -7,7 +7,7 @@ import (
|
|||
|
||||
type Addition struct {
|
||||
RefreshToken string `json:"refresh_token" required:"true"`
|
||||
driver.RootFolderPath
|
||||
driver.RootPath
|
||||
OrderBy string `json:"order_by" type:"select" options:"name,time,size" default:"name"`
|
||||
OrderDirection string `json:"order_direction" type:"select" options:"asc,desc" default:"asc"`
|
||||
DownloadAPI string `json:"download_api" type:"select" options:"official,crack" default:"official"`
|
||||
|
|
|
@ -9,7 +9,7 @@ type Addition struct {
|
|||
Address string `json:"address" required:"true"`
|
||||
Username string `json:"username" required:"true"`
|
||||
Password string `json:"password" required:"true"`
|
||||
driver.RootFolderPath
|
||||
driver.RootPath
|
||||
}
|
||||
|
||||
var config = driver.Config{
|
||||
|
|
|
@ -6,7 +6,7 @@ import (
|
|||
)
|
||||
|
||||
type Addition struct {
|
||||
driver.RootFolderID
|
||||
driver.RootID
|
||||
RefreshToken string `json:"refresh_token" required:"true"`
|
||||
OrderBy string `json:"order_by" type:"string" help:"such as: folder,name,modifiedTime"`
|
||||
OrderDirection string `json:"order_direction" type:"select" options:"asc,desc"`
|
||||
|
|
|
@ -18,7 +18,6 @@ import (
|
|||
"github.com/alist-org/alist/v3/internal/driver"
|
||||
"github.com/alist-org/alist/v3/internal/errs"
|
||||
"github.com/alist-org/alist/v3/internal/model"
|
||||
"github.com/alist-org/alist/v3/internal/op"
|
||||
"github.com/alist-org/alist/v3/pkg/utils"
|
||||
"github.com/alist-org/alist/v3/server/common"
|
||||
"github.com/disintegration/imaging"
|
||||
|
@ -39,17 +38,17 @@ func (d *Local) Init(ctx context.Context, storage model.Storage) error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if !utils.Exists(d.RootFolder) {
|
||||
err = fmt.Errorf("root folder %s not exists", d.RootFolder)
|
||||
if !utils.Exists(d.GetRootPath()) {
|
||||
err = fmt.Errorf("root folder %s not exists", d.GetRootPath())
|
||||
} else {
|
||||
if !filepath.IsAbs(d.RootFolder) {
|
||||
d.RootFolder, err = filepath.Abs(d.RootFolder)
|
||||
if !filepath.IsAbs(d.GetRootPath()) {
|
||||
abs, err := filepath.Abs(d.GetRootPath())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
d.SetRootPath(abs)
|
||||
}
|
||||
}
|
||||
op.MustSaveDriverStorage(d)
|
||||
return err
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ import (
|
|||
)
|
||||
|
||||
type Addition struct {
|
||||
driver.RootFolderPath
|
||||
driver.RootPath
|
||||
Thumbnail bool `json:"thumbnail" required:"true" help:"enable thumbnail"`
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ import (
|
|||
)
|
||||
|
||||
type Addition struct {
|
||||
driver.RootFolderPath
|
||||
driver.RootPath
|
||||
Region string `json:"region" type:"select" required:"true" options:"global,cn,us,de"`
|
||||
IsSharepoint bool `json:"is_sharepoint"`
|
||||
ClientID string `json:"client_id" required:"true"`
|
||||
|
|
|
@ -6,7 +6,7 @@ import (
|
|||
)
|
||||
|
||||
type Addition struct {
|
||||
driver.RootFolderID
|
||||
driver.RootID
|
||||
Username string `json:"username" required:"true"`
|
||||
Password string `json:"password" required:"true"`
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ import (
|
|||
|
||||
type Addition struct {
|
||||
Cookie string `json:"cookie" required:"true"`
|
||||
driver.RootFolderID
|
||||
driver.RootID
|
||||
OrderBy string `json:"order_by" type:"select" options:"file_type,file_name,updated_at" default:"file_name"`
|
||||
OrderDirection string `json:"order_direction" type:"select" options:"asc,desc" default:"asc"`
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ import (
|
|||
)
|
||||
|
||||
type Addition struct {
|
||||
driver.RootFolderPath
|
||||
driver.RootPath
|
||||
Bucket string `json:"bucket" required:"true"`
|
||||
Endpoint string `json:"endpoint" required:"true"`
|
||||
Region string `json:"region"`
|
||||
|
|
|
@ -10,7 +10,7 @@ type Addition struct {
|
|||
Username string `json:"username" required:"true"`
|
||||
PrivateKey string `json:"private_key" type:"text"`
|
||||
Password string `json:"password"`
|
||||
driver.RootFolderPath
|
||||
driver.RootPath
|
||||
}
|
||||
|
||||
var config = driver.Config{
|
||||
|
|
|
@ -9,7 +9,7 @@ type Addition struct {
|
|||
Region string `json:"region" type:"select" options:"china,international" required:"true"`
|
||||
Cookie string `json:"cookie" required:"true"`
|
||||
ProjectID string `json:"project_id" required:"true"`
|
||||
driver.RootFolderID
|
||||
driver.RootID
|
||||
OrderBy string `json:"order_by" type:"select" options:"fileName,fileSize,updated,created" default:"fileName"`
|
||||
OrderDirection string `json:"order_direction" type:"select" options:"Asc,Desc" default:"Asc"`
|
||||
}
|
||||
|
|
|
@ -7,8 +7,8 @@ import (
|
|||
|
||||
type Addition struct {
|
||||
// Usually one of two
|
||||
driver.RootFolderPath
|
||||
driver.RootFolderID
|
||||
driver.RootPath
|
||||
driver.RootID
|
||||
// define other
|
||||
Field string `json:"field" type:"select" required:"true" options:"a,b,c" default:"a"`
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ import (
|
|||
)
|
||||
|
||||
type Addition struct {
|
||||
driver.RootFolderPath
|
||||
driver.RootPath
|
||||
Bucket string `json:"bucket" required:"true"`
|
||||
Endpoint string `json:"endpoint" required:"true"`
|
||||
OperatorName string `json:"operator_name" required:"true"`
|
||||
|
|
|
@ -6,7 +6,7 @@ import (
|
|||
)
|
||||
|
||||
type Addition struct {
|
||||
driver.RootFolderPath
|
||||
driver.RootPath
|
||||
NumFile int `json:"num_file" type:"number" default:"30" required:"true"`
|
||||
NumFolder int `json:"num_folder" type:"number" default:"30" required:"true"`
|
||||
MaxFileSize int64 `json:"max_file_size" type:"number" default:"1073741824" required:"true"`
|
||||
|
|
|
@ -19,26 +19,30 @@ type Info struct {
|
|||
Config Config `json:"config"`
|
||||
}
|
||||
|
||||
type IRootFolderPath interface {
|
||||
GetRootFolderPath() string
|
||||
type IRootPath interface {
|
||||
GetRootPath() string
|
||||
}
|
||||
|
||||
type IRootFolderId interface {
|
||||
GetRootFolderId() string
|
||||
type IRootId interface {
|
||||
GetRootId() string
|
||||
}
|
||||
|
||||
type RootFolderPath struct {
|
||||
RootFolder string `json:"root_folder" required:"true" help:"Root folder path"`
|
||||
type RootPath struct {
|
||||
RootFolderPath string `json:"root_folder_path" required:"true"`
|
||||
}
|
||||
|
||||
type RootFolderID struct {
|
||||
RootFolder string `json:"root_folder" required:"true" help:"Root folder id"`
|
||||
type RootID struct {
|
||||
RootFolderID string `json:"root_folder_id" required:"true"`
|
||||
}
|
||||
|
||||
func (r RootFolderPath) GetRootFolderPath() string {
|
||||
return r.RootFolder
|
||||
func (r RootPath) GetRootPath() string {
|
||||
return r.RootFolderPath
|
||||
}
|
||||
|
||||
func (r RootFolderID) GetRootFolderId() string {
|
||||
return r.RootFolder
|
||||
func (r *RootPath) SetRootPath(path string) {
|
||||
r.RootFolderPath = path
|
||||
}
|
||||
|
||||
func (r RootID) GetRootId() string {
|
||||
return r.RootFolderID
|
||||
}
|
||||
|
|
|
@ -87,18 +87,18 @@ func Get(ctx context.Context, storage driver.Driver, path string) (model.Obj, er
|
|||
}
|
||||
}
|
||||
// is root folder
|
||||
if r, ok := storage.GetAddition().(driver.IRootFolderId); ok && utils.PathEqual(path, "/") {
|
||||
if r, ok := storage.GetAddition().(driver.IRootId); ok && utils.PathEqual(path, "/") {
|
||||
return &model.Object{
|
||||
ID: r.GetRootFolderId(),
|
||||
ID: r.GetRootId(),
|
||||
Name: "root",
|
||||
Size: 0,
|
||||
Modified: storage.GetStorage().Modified,
|
||||
IsFolder: true,
|
||||
}, nil
|
||||
}
|
||||
if r, ok := storage.GetAddition().(driver.IRootFolderPath); ok && isRoot(path, r.GetRootFolderPath()) {
|
||||
if r, ok := storage.GetAddition().(driver.IRootPath); ok && isRoot(path, r.GetRootPath()) {
|
||||
return &model.Object{
|
||||
Path: r.GetRootFolderPath(),
|
||||
Path: r.GetRootPath(),
|
||||
Name: "root",
|
||||
Size: 0,
|
||||
Modified: storage.GetStorage().Modified,
|
||||
|
|
|
@ -14,8 +14,8 @@ import (
|
|||
// ActualPath Get the actual path
|
||||
// !!! maybe and \ in the path when use windows local
|
||||
func ActualPath(storage driver.Additional, rawPath string) string {
|
||||
if i, ok := storage.(driver.IRootFolderPath); ok {
|
||||
rawPath = stdpath.Join(i.GetRootFolderPath(), rawPath)
|
||||
if i, ok := storage.(driver.IRootPath); ok {
|
||||
rawPath = stdpath.Join(i.GetRootPath(), rawPath)
|
||||
}
|
||||
return utils.StandardizePath(rawPath)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue