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

@ -34,12 +34,7 @@ func (d *Local) Config() driver.Config {
return config
}
func (d *Local) 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 *Local) Init(ctx context.Context) (err error) {
if !utils.Exists(d.GetRootPath()) {
err = fmt.Errorf("root folder %s not exists", d.GetRootPath())
} else {
@ -59,7 +54,7 @@ func (d *Local) Drop(ctx context.Context) error {
}
func (d *Local) GetAddition() driver.Additional {
return d.Addition
return &d.Addition
}
func (d *Local) List(ctx context.Context, dir model.Obj, args model.ListArgs) ([]model.Obj, error) {