mirror of https://github.com/Xhofe/alist
feat: standardization virtual path while create and update
parent
04f43cb684
commit
355db3ab9b
|
@ -31,6 +31,7 @@ func GetAccountByVirtualPath(virtualPath string) (driver.Driver, error) {
|
||||||
// then instantiate corresponding driver and save it in memory
|
// then instantiate corresponding driver and save it in memory
|
||||||
func CreateAccount(ctx context.Context, account model.Account) error {
|
func CreateAccount(ctx context.Context, account model.Account) error {
|
||||||
account.Modified = time.Now()
|
account.Modified = time.Now()
|
||||||
|
account.VirtualPath = utils.StandardizationPath(account.VirtualPath)
|
||||||
err := store.CreateAccount(&account)
|
err := store.CreateAccount(&account)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.WithMessage(err, "failed create account in database")
|
return errors.WithMessage(err, "failed create account in database")
|
||||||
|
@ -59,6 +60,7 @@ func UpdateAccount(ctx context.Context, account model.Account) error {
|
||||||
return errors.WithMessage(err, "failed get old account")
|
return errors.WithMessage(err, "failed get old account")
|
||||||
}
|
}
|
||||||
account.Modified = time.Now()
|
account.Modified = time.Now()
|
||||||
|
account.VirtualPath = utils.StandardizationPath(account.VirtualPath)
|
||||||
err = store.UpdateAccount(&account)
|
err = store.UpdateAccount(&account)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.WithMessage(err, "failed update account in database")
|
return errors.WithMessage(err, "failed update account in database")
|
||||||
|
|
Loading…
Reference in New Issue