refactor: optimize driver initialization need to manually deserialize and assign values, and remove redundant driver registration parameters (#2691)

* refactor: optimize driver initialization need to manually deserialize and assign values, and remove redundant driver registration parameters

* fix typo

Co-authored-by: Noah Hsu <i@nn.ci>
This commit is contained in:
foxxorcat
2022-12-13 18:03:30 +08:00
committed by GitHub
parent 3ee45c69a7
commit 33bae52fa1
67 changed files with 194 additions and 392 deletions

View File

@ -10,7 +10,6 @@ import (
"github.com/alist-org/alist/v3/internal/errs"
"github.com/alist-org/alist/v3/internal/model"
"github.com/alist-org/alist/v3/pkg/chanio"
"github.com/alist-org/alist/v3/pkg/utils"
log "github.com/sirupsen/logrus"
"github.com/t3rm1n4l/go-mega"
)
@ -26,15 +25,10 @@ func (d *Mega) Config() driver.Config {
}
func (d *Mega) GetAddition() driver.Additional {
return d.Addition
return &d.Addition
}
func (d *Mega) Init(ctx context.Context, storage model.Storage) error {
d.Storage = storage
err := utils.Json.UnmarshalFromString(d.Storage.Addition, &d.Addition)
if err != nil {
return err
}
func (d *Mega) Init(ctx context.Context) error {
d.c = mega.New()
return d.c.Login(d.Email, d.Password)
}