Skip to content

Commit

Permalink
feat(local): check root folder while init
Browse files Browse the repository at this point in the history
  • Loading branch information
xhofe committed Jun 15, 2022
1 parent 9fcdbec commit 4fa7846
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
10 changes: 9 additions & 1 deletion drivers/local/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (

"github.com/alist-org/alist/v3/internal/driver"
"github.com/alist-org/alist/v3/internal/model"
"github.com/alist-org/alist/v3/internal/operations"
"github.com/alist-org/alist/v3/pkg/utils"
"github.com/pkg/errors"
)
Expand All @@ -25,7 +26,14 @@ func (d *Driver) Init(ctx context.Context, account model.Account) error {
if err != nil {
return errors.Wrap(err, "error while unmarshal addition")
}
return nil
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
}

func (d *Driver) Drop(ctx context.Context) error {
Expand Down
4 changes: 4 additions & 0 deletions internal/model/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,7 @@ type Proxy struct {
func (a Account) GetAccount() Account {
return a
}

func (a *Account) SetStatus(status string) {
a.Status = status
}

0 comments on commit 4fa7846

Please sign in to comment.