🚧 aliyundrive webdav write

This commit is contained in:
微凉
2021-12-06 17:49:20 +08:00
parent 1779617cb9
commit 28998d6f8c
11 changed files with 278 additions and 43 deletions

25
drivers/base/cache.go Normal file
View File

@ -0,0 +1,25 @@
package base
import (
"fmt"
"github.com/Xhofe/alist/conf"
"github.com/Xhofe/alist/model"
"github.com/Xhofe/alist/utils"
)
func KeyCache(path string, account *model.Account) string {
path = utils.ParsePath(path)
return fmt.Sprintf("%s%s", account.Name, path)
}
func SetCache(path string, obj interface{}, account *model.Account) error {
return conf.Cache.Set(conf.Ctx, KeyCache(path, account), obj, nil)
}
func GetCache(path string, account *model.Account) (interface{}, error) {
return conf.Cache.Get(conf.Ctx, fmt.Sprintf("%s%s", KeyCache(path, account)))
}
func DeleteCache(path string, account *model.Account) error {
return conf.Cache.Delete(conf.Ctx, fmt.Sprintf("%s%s", KeyCache(path, account)))
}

View File

@ -41,11 +41,6 @@ type Item struct {
Description string `json:"description"`
}
type TokenResp struct {
AccessToken string `json:"access_token"`
RefreshToken string `json:"refresh_token"`
}
var driversMap = map[string]Driver{}
func RegisterDriver(driver Driver) {
@ -68,14 +63,14 @@ func GetDrivers() map[string][]Item {
{
Name: "proxy",
Label: "proxy",
Type: "bool",
Type: TypeBool,
Required: true,
Description: "allow proxy",
},
{
Name: "webdav_proxy",
Label: "webdav proxy",
Type: "bool",
Type: TypeBool,
Required: true,
Description: "Transfer the WebDAV of this account through the server",
},
@ -85,8 +80,6 @@ func GetDrivers() map[string][]Item {
return res
}
type Json map[string]interface{}
var NoRedirectClient *resty.Client
func init() {

View File

@ -1,12 +1,15 @@
package base
import "fmt"
import (
"errors"
)
var (
ErrPathNotFound = fmt.Errorf("path not found")
ErrNotFile = fmt.Errorf("not file")
ErrNotImplement = fmt.Errorf("not implement")
ErrNotSupport = fmt.Errorf("not support")
ErrPathNotFound = errors.New("path not found")
ErrNotFile = errors.New("not file")
ErrNotImplement = errors.New("not implement")
ErrNotSupport = errors.New("not support")
ErrNotFolder = errors.New("not a folder")
)
const (
@ -15,3 +18,10 @@ const (
TypeBool = "bool"
TypeNumber = "number"
)
type Json map[string]interface{}
type TokenResp struct {
AccessToken string `json:"access_token"`
RefreshToken string `json:"refresh_token"`
}