mirror of https://github.com/Xhofe/alist
parent
0f0e1104a4
commit
b1e662cd34
|
@ -9,6 +9,7 @@ import (
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"github.com/robfig/cron/v3"
|
"github.com/robfig/cron/v3"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
|
"path/filepath"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Onedrive struct{}
|
type Onedrive struct{}
|
||||||
|
@ -129,12 +130,27 @@ func (driver Onedrive) Save(account *model.Account, old *model.Account) error {
|
||||||
|
|
||||||
func (driver Onedrive) File(path string, account *model.Account) (*model.File, error) {
|
func (driver Onedrive) File(path string, account *model.Account) (*model.File, error) {
|
||||||
path = utils.ParsePath(path)
|
path = utils.ParsePath(path)
|
||||||
rawFile, err := driver.GetFile(account, path)
|
if path == "/" {
|
||||||
|
return &model.File{
|
||||||
|
Id: account.RootFolder,
|
||||||
|
Name: account.Name,
|
||||||
|
Size: 0,
|
||||||
|
Type: conf.FOLDER,
|
||||||
|
Driver: driverName,
|
||||||
|
UpdatedAt: account.UpdatedAt,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
dir, name := filepath.Split(path)
|
||||||
|
files, err := driver.Files(dir, account)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
file := driver.FormatFile(rawFile)
|
for _, file := range files {
|
||||||
return file, nil
|
if file.Name == name {
|
||||||
|
return &file, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil, drivers.PathNotFound
|
||||||
}
|
}
|
||||||
|
|
||||||
func (driver Onedrive) Files(path string, account *model.Account) ([]model.File, error) {
|
func (driver Onedrive) Files(path string, account *model.Account) ([]model.File, error) {
|
||||||
|
|
Loading…
Reference in New Issue