feat: set account modified time

refactor/fs
Noah Hsu 2022-06-10 16:51:20 +08:00
parent 7b6f11fa52
commit c5e5666b64
1 changed files with 3 additions and 0 deletions

View File

@ -11,6 +11,7 @@ import (
"sort"
"strings"
"sync"
"time"
)
// Although the driver type is stored,
@ -29,6 +30,7 @@ func GetAccountByVirtualPath(virtualPath string) (driver.Driver, error) {
// CreateAccount Save the account to database so account can get an id
// then instantiate corresponding driver and save it in memory
func CreateAccount(ctx context.Context, account model.Account) error {
account.Modified = time.Now()
err := store.CreateAccount(&account)
if err != nil {
return errors.WithMessage(err, "failed create account in database")
@ -56,6 +58,7 @@ func UpdateAccount(ctx context.Context, account model.Account) error {
if err != nil {
return errors.WithMessage(err, "failed get old account")
}
account.Modified = time.Now()
err = store.UpdateAccount(&account)
if err != nil {
return errors.WithMessage(err, "failed update account in database")