alist/drivers/local/driver.go

93 lines
2.2 KiB
Go
Raw Normal View History

2022-06-06 14:06:33 +00:00
package local
2022-06-07 10:13:55 +00:00
import (
"context"
2022-06-14 11:44:25 +00:00
2022-06-07 10:13:55 +00:00
"github.com/alist-org/alist/v3/internal/driver"
"github.com/alist-org/alist/v3/internal/model"
"github.com/alist-org/alist/v3/internal/operations"
2022-06-07 10:13:55 +00:00
"github.com/alist-org/alist/v3/pkg/utils"
2022-06-09 09:11:46 +00:00
"github.com/pkg/errors"
2022-06-07 10:13:55 +00:00
)
type Driver struct {
model.Account
Addition
}
func (d Driver) Config() driver.Config {
return config
}
func (d *Driver) Init(ctx context.Context, account model.Account) error {
2022-06-07 14:02:41 +00:00
d.Account = account
2022-06-07 10:13:55 +00:00
addition := d.Account.Addition
2022-06-14 11:44:25 +00:00
err := utils.Json.UnmarshalFromString(addition, &d.Addition)
2022-06-07 10:13:55 +00:00
if err != nil {
2022-06-09 09:11:46 +00:00
return errors.Wrap(err, "error while unmarshal addition")
2022-06-07 10:13:55 +00:00
}
if !utils.Exists(d.RootFolder) {
err = errors.Errorf("root folder %s not exists", d.RootFolder)
d.SetStatus(err.Error())
} else {
d.SetStatus("OK")
}
operations.SaveDriverAccount(d)
return err
2022-06-07 10:13:55 +00:00
}
func (d *Driver) Drop(ctx context.Context) error {
2022-06-07 14:02:41 +00:00
return nil
2022-06-07 10:13:55 +00:00
}
2022-06-08 08:20:58 +00:00
func (d *Driver) GetAddition() driver.Additional {
return d.Addition
2022-06-07 10:13:55 +00:00
}
2022-06-15 12:31:23 +00:00
func (d *Driver) List(ctx context.Context, dir model.Object) ([]model.Object, error) {
2022-06-07 10:13:55 +00:00
//TODO implement me
panic("implement me")
}
2022-06-15 12:31:23 +00:00
func (d *Driver) Link(ctx context.Context, file model.Object, args model.LinkArgs) (*model.Link, error) {
2022-06-07 10:13:55 +00:00
//TODO implement me
panic("implement me")
}
2022-06-15 12:31:23 +00:00
func (d *Driver) MakeDir(ctx context.Context, parentDir model.Object, dirName string) error {
2022-06-07 14:02:41 +00:00
//TODO implement me
panic("implement me")
}
2022-06-15 12:31:23 +00:00
func (d *Driver) Move(ctx context.Context, srcObject, dstDir model.Object) error {
2022-06-07 10:13:55 +00:00
//TODO implement me
panic("implement me")
}
2022-06-15 12:31:23 +00:00
func (d *Driver) Rename(ctx context.Context, srcObject model.Object, newName string) error {
2022-06-07 10:13:55 +00:00
//TODO implement me
panic("implement me")
}
2022-06-15 12:31:23 +00:00
func (d *Driver) Copy(ctx context.Context, srcObject, dstDir model.Object) error {
2022-06-07 10:13:55 +00:00
//TODO implement me
panic("implement me")
}
2022-06-15 12:31:23 +00:00
func (d *Driver) Remove(ctx context.Context, object model.Object) error {
2022-06-07 10:13:55 +00:00
//TODO implement me
panic("implement me")
}
2022-06-15 12:31:23 +00:00
func (d *Driver) Put(ctx context.Context, parentDir model.Object, stream model.FileStreamer) error {
2022-06-07 10:13:55 +00:00
//TODO implement me
panic("implement me")
}
2022-06-15 12:31:23 +00:00
func (d Driver) Other(ctx context.Context, data interface{}) (interface{}, error) {
2022-06-07 10:13:55 +00:00
//TODO implement me
panic("implement me")
}
var _ driver.Driver = (*Driver)(nil)