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"
|
2022-06-15 10:48:30 +00:00
|
|
|
"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-17 13:23:44 +00:00
|
|
|
err := utils.Json.UnmarshalFromString(d.Account.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
|
|
|
}
|
2022-06-15 10:48:30 +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")
|
|
|
|
}
|
2022-06-17 13:23:44 +00:00
|
|
|
operations.MustSaveDriverAccount(d)
|
2022-06-15 10:48:30 +00:00
|
|
|
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:41:17 +00:00
|
|
|
func (d *Driver) List(ctx context.Context, dir model.Obj) ([]model.Obj, error) {
|
2022-06-07 10:13:55 +00:00
|
|
|
//TODO implement me
|
|
|
|
panic("implement me")
|
|
|
|
}
|
|
|
|
|
2022-06-15 12:41:17 +00:00
|
|
|
func (d *Driver) Link(ctx context.Context, file model.Obj, args model.LinkArgs) (*model.Link, error) {
|
2022-06-07 10:13:55 +00:00
|
|
|
//TODO implement me
|
|
|
|
panic("implement me")
|
|
|
|
}
|
|
|
|
|
2022-06-15 12:41:17 +00:00
|
|
|
func (d *Driver) MakeDir(ctx context.Context, parentDir model.Obj, dirName string) error {
|
2022-06-07 14:02:41 +00:00
|
|
|
//TODO implement me
|
|
|
|
panic("implement me")
|
|
|
|
}
|
|
|
|
|
2022-06-15 12:41:17 +00:00
|
|
|
func (d *Driver) Move(ctx context.Context, srcObj, dstDir model.Obj) error {
|
2022-06-07 10:13:55 +00:00
|
|
|
//TODO implement me
|
|
|
|
panic("implement me")
|
|
|
|
}
|
|
|
|
|
2022-06-15 12:41:17 +00:00
|
|
|
func (d *Driver) Rename(ctx context.Context, srcObj model.Obj, newName string) error {
|
2022-06-07 10:13:55 +00:00
|
|
|
//TODO implement me
|
|
|
|
panic("implement me")
|
|
|
|
}
|
|
|
|
|
2022-06-15 12:41:17 +00:00
|
|
|
func (d *Driver) Copy(ctx context.Context, srcObj, dstDir model.Obj) error {
|
2022-06-07 10:13:55 +00:00
|
|
|
//TODO implement me
|
|
|
|
panic("implement me")
|
|
|
|
}
|
|
|
|
|
2022-06-15 12:41:17 +00:00
|
|
|
func (d *Driver) Remove(ctx context.Context, obj model.Obj) error {
|
2022-06-07 10:13:55 +00:00
|
|
|
//TODO implement me
|
|
|
|
panic("implement me")
|
|
|
|
}
|
|
|
|
|
2022-06-20 14:29:52 +00:00
|
|
|
func (d *Driver) Put(ctx context.Context, dstDir model.Obj, stream model.FileStreamer, up driver.UpdateProgress) 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)
|