mirror of https://github.com/Xhofe/alist
				
				
				
			✨ simplify delete account when change name
							parent
							
								
									e8d27a30b4
								
							
						
					
					
						commit
						e4d254e4b0
					
				|  | @ -69,7 +69,6 @@ func (c Cloud189) Items() []Item { | |||
| func (c Cloud189) Save(account *model.Account, old *model.Account) error { | ||||
| 	if old != nil && old.Name != account.Name { | ||||
| 		delete(client189Map, old.Name) | ||||
| 		model.DeleteAccountFromMap(old.Name) | ||||
| 	} | ||||
| 	if err := c.Login(account); err != nil { | ||||
| 		account.Status = err.Error() | ||||
|  |  | |||
|  | @ -349,9 +349,6 @@ 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)) | ||||
| 		if old.Name != account.Name { | ||||
| 			model.DeleteAccountFromMap(old.Name) | ||||
| 		} | ||||
| 	} | ||||
| 	if account.RootFolder == "" { | ||||
| 		account.RootFolder = "root" | ||||
|  |  | |||
|  | @ -36,9 +36,6 @@ func (n Native) Proxy(c *gin.Context) { | |||
| } | ||||
| 
 | ||||
| func (n Native) Save(account *model.Account, old *model.Account) error { | ||||
| 	if old != nil { | ||||
| 		model.DeleteAccountFromMap(old.Name) | ||||
| 	} | ||||
| 	log.Debugf("save a account: [%s]", account.Name) | ||||
| 	if !utils.Exists(account.RootFolder) { | ||||
| 		account.Status = fmt.Sprintf("[%s] not exist", account.RootFolder) | ||||
|  |  | |||
|  | @ -273,9 +273,6 @@ func (o Onedrive) Save(account *model.Account, old *model.Account) error { | |||
| 	} | ||||
| 	if old != nil { | ||||
| 		conf.Cron.Remove(cron.EntryID(old.CronId)) | ||||
| 		if old.Name != account.Name { | ||||
| 			model.DeleteAccountFromMap(old.Name) | ||||
| 		} | ||||
| 	} | ||||
| 	account.RootFolder = utils.ParsePath(account.RootFolder) | ||||
| 	err := o.RefreshToken(account) | ||||
|  |  | |||
|  | @ -63,6 +63,9 @@ func SaveAccount(c *gin.Context) { | |||
| 	} | ||||
| 	now := time.Now() | ||||
| 	req.UpdatedAt = &now | ||||
| 	if old.Name != req.Name { | ||||
| 		model.DeleteAccountFromMap(old.Name) | ||||
| 	} | ||||
| 	if err := model.SaveAccount(&req); err != nil { | ||||
| 		ErrorResp(c, err, 500) | ||||
| 	} else { | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	 微凉
						微凉