Upload/Download update for error handling

This commit is contained in:
2019-09-25 20:59:15 -04:00
parent e53a972da5
commit 472d7b0d3b

15
main.go
View File

@ -97,12 +97,21 @@ func formatOutput(api keybase.ChatAPI) string {
}
func uploadFile(g *gocui.Gui, fileName string, fileTitle string) {
chat := k.NewChat(channel)
chat.Upload(fileTitle, fileName)
printToView(g, "Feed", fmt.Sprintf("You have uploaded %s to %s", fileName, channel.Name))
_, err := chat.Upload(fileTitle, fileName)
if err != nil {
printToView(g, "Feed", fmt.Sprintf("There was an error uploading %s to %s", fileName, channel.Name))
} else {
printToView(g, "Feed", fmt.Sprintf("Uploaded %s to %s", fileName, channel.Name))
}
}
func downloadFile(g *gocui.Gui, messageID int, fileName string) {
chat := k.NewChat(channel)
chat.Download(messageID, fmt.Sprintf("%s/%s", downloadPath, fileName))
_, err := chat.Download(messageID, fmt.Sprintf("%s/%s", downloadPath, fileName))
if err != nil {
printToView(g, "Feed", fmt.Sprintf("There was an error downloading %s from %s", fileName, channel.Name))
} else {
printToView(g, "Feed", fmt.Sprintf("Downloaded %s from %s", fileName, channel.Name))
}
}
func populateList(g *gocui.Gui) {