SaveAccount info also save profile pictures - #10
Conversation
3bl3gamer
left a comment
There was a problem hiding this comment.
Thank you for pull request and sorry for delay. Here are some comments.
| } | ||
| for _, d := range group { | ||
| chats = append(chats, d) //TODO: check duplicates | ||
| chats = append(chats, d) |
There was a problem hiding this comment.
Wouldn't it be easier to just check here if d.ID is already among chats? So whole removeDuplicateValues and if len(chats) > int(slice.Count) {...} will be unnecessary.
| file := tgGetPhotoFileInfo(photo) | ||
| tg.DownloadFileToPath(profilePicFPath+"_"+strconv.Itoa(index)+".jpg", file.InputLocation, file.DcID, int64(file.Size), NewFileProgressLogger()) | ||
| } | ||
| } |
There was a problem hiding this comment.
There should be
default:
return merry.Wrap(mtproto.WrongRespError(res))Otherwise this may silently fail on response error or after API update (if third TL_photos_photos* will appear).
| for index, photo := range photos.Photos { | ||
| photo := photo.(mtproto.TL_photo) | ||
| file := tgGetPhotoFileInfo(photo) | ||
| tg.DownloadFileToPath(profilePicFPath+"_"+strconv.Itoa(index)+".jpg", file.InputLocation, file.DcID, int64(file.Size), NewFileProgressLogger()) |
There was a problem hiding this comment.
tg.DownloadFileToPath
Error is dropped here. It should be checked and returned (as with regular file download in main.go).
profilePicFPath+"_"+strconv.Itoa(index)+".jpg"
This will write images to a path like history/profilepic_123.jpg? There is already a long list of history files in history/, and it's better not to mix it with another (profilepics) list. Maybe write them to history/profilepics/YYYY-MM-DD_HH-MM-SS.jpg (TL_photo has a Date field). It will also be possible to skip already loaded pictures.
No description provided.