feat: standardization virtual path while create and update

refactor/fs
Noah Hsu 2022-06-16 21:29:39 +08:00
parent 04f43cb684
commit 355db3ab9b
1 changed files with 2 additions and 0 deletions

View File

@ -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")