alist/internal/driver/driver.go

44 lines
1.1 KiB
Go
Raw Normal View History

2022-06-06 21:48:53 +08:00
package driver
import (
"context"
"github.com/alist-org/alist/v3/internal/model"
2022-06-06 21:48:53 +08:00
)
type Driver interface {
2022-06-07 22:02:41 +08:00
Meta
2022-06-06 21:48:53 +08:00
Reader
Writer
2022-06-07 22:02:41 +08:00
Other
2022-06-07 18:13:55 +08:00
}
2022-06-07 22:02:41 +08:00
type Meta interface {
2022-06-07 18:13:55 +08:00
Config() Config
2022-06-09 17:11:46 +08:00
// Init If already initialized, drop first
// need to unmarshal string to addition first
2022-06-07 18:13:55 +08:00
Init(ctx context.Context, account model.Account) error
Drop(ctx context.Context) error
2022-06-09 17:11:46 +08:00
// GetAccount just get raw account
2022-06-07 18:13:55 +08:00
GetAccount() model.Account
2022-06-08 16:20:58 +08:00
GetAddition() Additional
2022-06-06 21:48:53 +08:00
}
2022-06-07 22:02:41 +08:00
type Other interface {
Other(ctx context.Context, data interface{}) (interface{}, error)
}
2022-06-06 21:48:53 +08:00
type Reader interface {
List(ctx context.Context, path string) ([]FileInfo, error)
2022-06-10 21:00:51 +08:00
Link(ctx context.Context, path string, args LinkArgs) (*Link, error)
2022-06-11 14:43:03 +08:00
//Get(ctx context.Context, path string) (FileInfo, error) // maybe not need
2022-06-06 21:48:53 +08:00
}
type Writer interface {
MakeDir(ctx context.Context, path string) error
2022-06-10 21:00:51 +08:00
Move(ctx context.Context, srcPath, dstPath string) error
Rename(ctx context.Context, srcPath, dstName string) error
Copy(ctx context.Context, srcPath, dstPath string) error
2022-06-06 21:48:53 +08:00
Remove(ctx context.Context, path string) error
2022-06-10 21:00:51 +08:00
Put(ctx context.Context, parentPath string, stream FileStream) error
2022-06-06 21:48:53 +08:00
}