Skip to content

SaveAccount info also save profile pictures - #10

Open
patrizok wants to merge 3 commits into
3bl3gamer:masterfrom
patrizok:master
Open

SaveAccount info also save profile pictures#10
patrizok wants to merge 3 commits into
3bl3gamer:masterfrom
patrizok:master

Conversation

@patrizok

Copy link
Copy Markdown
Contributor

No description provided.

@3bl3gamer 3bl3gamer left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for pull request and sorry for delay. Here are some comments.

Comment thread tg.go
}
for _, d := range group {
chats = append(chats, d) //TODO: check duplicates
chats = append(chats, d)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread tg.go
file := tgGetPhotoFileInfo(photo)
tg.DownloadFileToPath(profilePicFPath+"_"+strconv.Itoa(index)+".jpg", file.InputLocation, file.DcID, int64(file.Size), NewFileProgressLogger())
}
}

@3bl3gamer 3bl3gamer Oct 1, 2021

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Comment thread tg.go
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())

@3bl3gamer 3bl3gamer Oct 1, 2021

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants