🐛 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

@ -347,6 +347,7 @@ func (a AliDrive) RefreshToken(account *model.Account) error {
func (a AliDrive) Save(account *model.Account, old *model.Account) error {
if old != nil {
conf.Cron.Remove(cron.EntryID(old.CronId))
model.DeleteAccountFromMap(old.Name)
}
if account.RootFolder == "" {
account.RootFolder = "root"
@ -367,7 +368,9 @@ func (a AliDrive) Save(account *model.Account, old *model.Account) error {
account.DriveId = resp["default_drive_id"].(string)
cronId, err := conf.Cron.AddFunc("@every 2h", func() {
name := account.Name
log.Debugf("ali account name: %s", name)
newAccount, ok := model.GetAccount(name)
log.Debugf("ali account: %+v", newAccount)
if !ok {
return
}