Browse Source

Upload/Download update for error handling

pull/1/head
Gregory Rudolph 5 years ago
parent
commit
472d7b0d3b
Signed by: rudi
GPG Key ID: EF64F3CBD1A1EBDD
  1. 15
      main.go

15
main.go

@ -97,12 +97,21 @@ func formatOutput(api keybase.ChatAPI) string { @@ -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) {

Loading…
Cancel
Save