fix baidu.photo and xunlei
This commit is contained in:
commit
b7d9c5e4ff
@ -9,7 +9,6 @@ import (
|
|||||||
"math"
|
"math"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
|
||||||
|
|
||||||
"github.com/Xhofe/alist/conf"
|
"github.com/Xhofe/alist/conf"
|
||||||
"github.com/Xhofe/alist/drivers/base"
|
"github.com/Xhofe/alist/drivers/base"
|
||||||
@ -81,7 +80,7 @@ func (driver Baidu) File(path string, account *model.Account) (*model.File, erro
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
dir, name := filepath.Split(path)
|
dir, name := utils.Split(path)
|
||||||
files, err := driver.Files(dir, account)
|
files, err := driver.Files(dir, account)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -123,7 +122,7 @@ func (driver Baidu) Files(path string, account *model.Account) ([]model.File, er
|
|||||||
Id: joinID(file.Fsid, file.Uk, file.Tid),
|
Id: joinID(file.Fsid, file.Uk, file.Tid),
|
||||||
Name: file.Name(),
|
Name: file.Name(),
|
||||||
Size: file.Size,
|
Size: file.Size,
|
||||||
Type: utils.GetFileType(filepath.Ext(file.Path)),
|
Type: utils.GetFileType(utils.Ext(file.Path)),
|
||||||
Driver: driver.Config().Name,
|
Driver: driver.Config().Name,
|
||||||
UpdatedAt: getTime(file.Mtime),
|
UpdatedAt: getTime(file.Mtime),
|
||||||
Thumbnail: thumbnail,
|
Thumbnail: thumbnail,
|
||||||
@ -165,7 +164,7 @@ func (driver Baidu) Link(args base.Args, account *model.Account) (*base.Link, er
|
|||||||
return nil, base.ErrNotSupport
|
return nil, base.ErrNotSupport
|
||||||
}
|
}
|
||||||
|
|
||||||
album, err := driver.File(filepath.Dir(utils.ParsePath(args.Path)), account)
|
album, err := driver.File(utils.Dir(utils.ParsePath(args.Path)), account)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -218,13 +217,13 @@ func (driver Baidu) Rename(src string, dst string, account *model.Account) error
|
|||||||
}
|
}
|
||||||
|
|
||||||
if IsAlbum(srcFile) {
|
if IsAlbum(srcFile) {
|
||||||
return driver.SetAlbumName(srcFile.Id, filepath.Base(dst), account)
|
return driver.SetAlbumName(srcFile.Id, utils.Base(dst), account)
|
||||||
}
|
}
|
||||||
return base.ErrNotSupport
|
return base.ErrNotSupport
|
||||||
}
|
}
|
||||||
|
|
||||||
func (driver Baidu) MakeDir(path string, account *model.Account) error {
|
func (driver Baidu) MakeDir(path string, account *model.Account) error {
|
||||||
dir, name := filepath.Split(path)
|
dir, name := utils.Split(path)
|
||||||
parentFile, err := driver.File(dir, account)
|
parentFile, err := driver.File(dir, account)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -244,7 +243,7 @@ func (driver Baidu) Move(src string, dst string, account *model.Account) error {
|
|||||||
|
|
||||||
if IsAlbumFile(srcFile) {
|
if IsAlbumFile(srcFile) {
|
||||||
// 移动相册文件
|
// 移动相册文件
|
||||||
dstAlbum, err := driver.File(filepath.Dir(dst), account)
|
dstAlbum, err := driver.File(utils.Dir(dst), account)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -252,7 +251,7 @@ func (driver Baidu) Move(src string, dst string, account *model.Account) error {
|
|||||||
return base.ErrNotSupport
|
return base.ErrNotSupport
|
||||||
}
|
}
|
||||||
|
|
||||||
srcAlbum, err := driver.File(filepath.Dir(src), account)
|
srcAlbum, err := driver.File(utils.Dir(src), account)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -282,7 +281,7 @@ func (driver Baidu) Copy(src string, dst string, account *model.Account) error {
|
|||||||
|
|
||||||
if IsAlbumFile(srcFile) {
|
if IsAlbumFile(srcFile) {
|
||||||
// 复制相册文件
|
// 复制相册文件
|
||||||
dstAlbum, err := driver.File(filepath.Dir(dst), account)
|
dstAlbum, err := driver.File(utils.Dir(dst), account)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -290,7 +289,7 @@ func (driver Baidu) Copy(src string, dst string, account *model.Account) error {
|
|||||||
return base.ErrNotSupport
|
return base.ErrNotSupport
|
||||||
}
|
}
|
||||||
|
|
||||||
srcAlbum, err := driver.File(filepath.Dir(src), account)
|
srcAlbum, err := driver.File(utils.Dir(src), account)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -322,7 +321,7 @@ func (driver Baidu) Delete(path string, account *model.Account) error {
|
|||||||
// 生成相册文件
|
// 生成相册文件
|
||||||
if IsAlbumFile(file) {
|
if IsAlbumFile(file) {
|
||||||
// 删除相册文件
|
// 删除相册文件
|
||||||
album, err := driver.File(filepath.Dir(path), account)
|
album, err := driver.File(utils.Dir(path), account)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,8 @@ package baiduphoto
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"path/filepath"
|
|
||||||
|
"github.com/Xhofe/alist/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
type TokenErrResp struct {
|
type TokenErrResp struct {
|
||||||
@ -45,7 +46,7 @@ type (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func (f File) Name() string {
|
func (f File) Name() string {
|
||||||
return filepath.Base(f.Path)
|
return utils.Base(f.Path)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*相册部分*/
|
/*相册部分*/
|
||||||
|
@ -211,7 +211,7 @@ func (c *Client) Request(method string, url string, callback func(*resty.Request
|
|||||||
"X-Captcha-Token": c.captchaToken,
|
"X-Captcha-Token": c.captchaToken,
|
||||||
"User-Agent": c.userAgent,
|
"User-Agent": c.userAgent,
|
||||||
"client_id": c.clientID,
|
"client_id": c.clientID,
|
||||||
})
|
}).SetQueryParam("client_id", c.clientID)
|
||||||
if callback != nil {
|
if callback != nil {
|
||||||
callback(req)
|
callback(req)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user