chore!: change root folder
This commit is contained in:
@ -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)
|
||||
}
|
||||
|
Reference in New Issue
Block a user