🐛 fix delete account when change name
This commit is contained in:
parent
69514668cc
commit
e8d27a30b4
@ -67,8 +67,9 @@ func (c Cloud189) Items() []Item {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c Cloud189) Save(account *model.Account, old *model.Account) error {
|
func (c Cloud189) Save(account *model.Account, old *model.Account) error {
|
||||||
if old != nil {
|
if old != nil && old.Name != account.Name {
|
||||||
delete(client189Map, old.Name)
|
delete(client189Map, old.Name)
|
||||||
|
model.DeleteAccountFromMap(old.Name)
|
||||||
}
|
}
|
||||||
if err := c.Login(account); err != nil {
|
if err := c.Login(account); err != nil {
|
||||||
account.Status = err.Error()
|
account.Status = err.Error()
|
||||||
|
@ -349,7 +349,9 @@ func (a AliDrive) RefreshToken(account *model.Account) error {
|
|||||||
func (a AliDrive) Save(account *model.Account, old *model.Account) error {
|
func (a AliDrive) Save(account *model.Account, old *model.Account) error {
|
||||||
if old != nil {
|
if old != nil {
|
||||||
conf.Cron.Remove(cron.EntryID(old.CronId))
|
conf.Cron.Remove(cron.EntryID(old.CronId))
|
||||||
model.DeleteAccountFromMap(old.Name)
|
if old.Name != account.Name {
|
||||||
|
model.DeleteAccountFromMap(old.Name)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if account.RootFolder == "" {
|
if account.RootFolder == "" {
|
||||||
account.RootFolder = "root"
|
account.RootFolder = "root"
|
||||||
|
@ -9,9 +9,9 @@ import (
|
|||||||
|
|
||||||
type Driver interface {
|
type Driver interface {
|
||||||
Items() []Item
|
Items() []Item
|
||||||
|
Save(account *model.Account, old *model.Account) error
|
||||||
Path(path string, account *model.Account) (*model.File, []*model.File, error)
|
Path(path string, account *model.Account) (*model.File, []*model.File, error)
|
||||||
Link(path string, account *model.Account) (string, error)
|
Link(path string, account *model.Account) (string, error)
|
||||||
Save(account *model.Account, old *model.Account) error
|
|
||||||
Proxy(c *gin.Context)
|
Proxy(c *gin.Context)
|
||||||
Preview(path string, account *model.Account) (interface{}, error)
|
Preview(path string, account *model.Account) (interface{}, error)
|
||||||
// TODO
|
// TODO
|
||||||
|
@ -17,7 +17,7 @@ type Native struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (n Native) Preview(path string, account *model.Account) (interface{}, error) {
|
func (n Native) Preview(path string, account *model.Account) (interface{}, error) {
|
||||||
return nil,fmt.Errorf("no need")
|
return nil, fmt.Errorf("no need")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n Native) Items() []Item {
|
func (n Native) Items() []Item {
|
||||||
@ -36,6 +36,9 @@ func (n Native) Proxy(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (n Native) Save(account *model.Account, old *model.Account) error {
|
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)
|
log.Debugf("save a account: [%s]", account.Name)
|
||||||
if !utils.Exists(account.RootFolder) {
|
if !utils.Exists(account.RootFolder) {
|
||||||
account.Status = fmt.Sprintf("[%s] not exist", account.RootFolder)
|
account.Status = fmt.Sprintf("[%s] not exist", account.RootFolder)
|
||||||
@ -73,7 +76,7 @@ func (n Native) Path(path string, account *model.Account) (*model.File, []*model
|
|||||||
Size: f.Size(),
|
Size: f.Size(),
|
||||||
Type: 0,
|
Type: 0,
|
||||||
UpdatedAt: &time,
|
UpdatedAt: &time,
|
||||||
Driver: "Native",
|
Driver: "Native",
|
||||||
}
|
}
|
||||||
if f.IsDir() {
|
if f.IsDir() {
|
||||||
file.Type = conf.FOLDER
|
file.Type = conf.FOLDER
|
||||||
@ -94,7 +97,7 @@ func (n Native) Path(path string, account *model.Account) (*model.File, []*model
|
|||||||
Size: f.Size(),
|
Size: f.Size(),
|
||||||
Type: utils.GetFileType(filepath.Ext(f.Name())),
|
Type: utils.GetFileType(filepath.Ext(f.Name())),
|
||||||
UpdatedAt: &time,
|
UpdatedAt: &time,
|
||||||
Driver: "Native",
|
Driver: "Native",
|
||||||
}
|
}
|
||||||
return file, nil, nil
|
return file, nil, nil
|
||||||
}
|
}
|
||||||
|
@ -273,7 +273,9 @@ func (o Onedrive) Save(account *model.Account, old *model.Account) error {
|
|||||||
}
|
}
|
||||||
if old != nil {
|
if old != nil {
|
||||||
conf.Cron.Remove(cron.EntryID(old.CronId))
|
conf.Cron.Remove(cron.EntryID(old.CronId))
|
||||||
model.DeleteAccountFromMap(old.Name)
|
if old.Name != account.Name {
|
||||||
|
model.DeleteAccountFromMap(old.Name)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
account.RootFolder = utils.ParsePath(account.RootFolder)
|
account.RootFolder = utils.ParsePath(account.RootFolder)
|
||||||
err := o.RefreshToken(account)
|
err := o.RefreshToken(account)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user