🐛 fix change name error

This commit is contained in:
微凉
2021-11-15 14:54:22 +08:00
parent aeb72320ca
commit 27e61c9eb8
4 changed files with 26 additions and 6 deletions

View File

@ -8,6 +8,7 @@ import (
"github.com/gin-gonic/gin"
"github.com/go-resty/resty/v2"
"github.com/robfig/cron/v3"
log "github.com/sirupsen/logrus"
"path/filepath"
"time"
)
@ -269,6 +270,7 @@ func (o Onedrive) Save(account *model.Account, old *model.Account) error {
}
if old != nil {
conf.Cron.Remove(cron.EntryID(old.CronId))
model.DeleteAccountFromMap(old.Name)
}
account.RootFolder = utils.ParsePath(account.RootFolder)
err := o.RefreshToken(account)
@ -277,7 +279,9 @@ func (o Onedrive) Save(account *model.Account, old *model.Account) error {
}
cronId, err := conf.Cron.AddFunc("@every 1h", func() {
name := account.Name
log.Debugf("onedrive account name: %s", name)
newAccount, ok := model.GetAccount(name)
log.Debugf("onedrive account: %+v", newAccount)
if !ok {
return
}