chore: baidu_photo rename only duplicate folders

pull/1831/head
foxxorcat 2022-09-15 09:25:20 +08:00
parent 7ad3748a46
commit f22232de5d
2 changed files with 11 additions and 5 deletions

View File

@ -65,10 +65,16 @@ func (d *BaiduPhoto) List(ctx context.Context, dir model.Obj, args model.ListArg
}
}
objs = make([]model.Obj, 0, len(files)+len(albums))
for i := 0; i < len(albums); i++ {
objs = append(objs, &albums[i])
}
alubmName := make(map[string]int)
objs, _ = utils.SliceConvert(albums, func(album Album) (model.Obj, error) {
i := alubmName[album.GetName()]
if i != 0 {
alubmName[album.GetName()]++
album.Title = fmt.Sprintf("%s(%d)", album.Title, i)
}
alubmName[album.GetName()]++
return &album, nil
})
for i := 0; i < len(files); i++ {
objs = append(objs, &files[i])
}

View File

@ -100,7 +100,7 @@ type (
)
func (a *Album) GetSize() int64 { return 0 }
func (a *Album) GetName() string { return fmt.Sprint(a.Title, " -> ", a.AlbumID) }
func (a *Album) GetName() string { return fmt.Sprint(a.Title) }
func (a *Album) ModTime() time.Time {
if a.parseTime == nil {
a.parseTime = toTime(a.Mtime)