alist/internal/driver/driver.go

44 lines
1.1 KiB
Go
Raw Normal View History

2022-06-06 13:48:53 +00:00
package driver
import (
"context"
"github.com/alist-org/alist/v3/internal/model"
2022-06-06 13:48:53 +00:00
)
type Driver interface {
2022-06-07 14:02:41 +00:00
Meta
2022-06-06 13:48:53 +00:00
Reader
Writer
2022-06-07 14:02:41 +00:00
Other
2022-06-07 10:13:55 +00:00
}
2022-06-07 14:02:41 +00:00
type Meta interface {
2022-06-07 10:13:55 +00:00
Config() Config
2022-06-09 09:11:46 +00:00
// Init If already initialized, drop first
// need to unmarshal string to addition first
2022-06-07 10:13:55 +00:00
Init(ctx context.Context, account model.Account) error
Drop(ctx context.Context) error
2022-06-09 09:11:46 +00:00
// GetAccount just get raw account
2022-06-07 10:13:55 +00:00
GetAccount() model.Account
2022-06-08 08:20:58 +00:00
GetAddition() Additional
2022-06-06 13:48:53 +00:00
}
2022-06-07 14:02:41 +00:00
type Other interface {
Other(ctx context.Context, data interface{}) (interface{}, error)
}
2022-06-06 13:48:53 +00:00
type Reader interface {
2022-06-10 12:20:45 +00:00
Get(ctx context.Context, path string) (FileInfo, error)
2022-06-06 13:48:53 +00:00
List(ctx context.Context, path string) ([]FileInfo, error)
2022-06-10 13:00:51 +00:00
Link(ctx context.Context, path string, args LinkArgs) (*Link, error)
2022-06-06 13:48:53 +00:00
}
type Writer interface {
MakeDir(ctx context.Context, path string) error
2022-06-10 13:00:51 +00: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 13:48:53 +00:00
Remove(ctx context.Context, path string) error
2022-06-10 13:00:51 +00:00
Put(ctx context.Context, parentPath string, stream FileStream) error
2022-06-06 13:48:53 +00:00
}