Skip to content

Commit

Permalink
retry EOF
Browse files Browse the repository at this point in the history
  • Loading branch information
aschey committed Aug 16, 2024
1 parent fc6e356 commit f42f8fa
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
4 changes: 2 additions & 2 deletions platune-cli/cmd/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ func expandFile(song string) (string, error) {
full, stat, err := expandPath(song)

if stat != nil && stat.Mode().IsDir() {
return "", fmt.Errorf("Cannot add a directory")
return "", fmt.Errorf("cannot add a directory")
}
return full, err
}
Expand All @@ -226,7 +226,7 @@ func expandFolder(song string) (string, error) {
full, stat, err := expandPath(song)

if stat != nil && !stat.Mode().IsDir() {
return "", fmt.Errorf("Cannot add a file")
return "", fmt.Errorf("cannot add a file")
}
return full, err
}
Expand Down
2 changes: 1 addition & 1 deletion platune-cli/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func newRootCmd() *cobra.Command {
if interactive {
exitCode := state.RunInteractive()
if exitCode != 0 {
return fmt.Errorf("Prompt exited with code %d", exitCode)
return fmt.Errorf("prompt exited with code %d", exitCode)
} else {
return nil
}
Expand Down
12 changes: 11 additions & 1 deletion platune-cli/internal/platune_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package internal
import (
"context"
"fmt"
"io"
"math"
"os"
"strconv"
Expand Down Expand Up @@ -96,6 +97,10 @@ func (p *PlatuneClient) SubscribePlayerEvents(eventCh chan *platune.EventRespons
}

msg, err := (*p.playerEventClient).Recv()
if err == io.EOF {
p.ResetStreams()
msg, err = (*p.playerEventClient).Recv()
}
if err == nil {
eventCh <- msg
}
Expand Down Expand Up @@ -302,7 +307,12 @@ func (p *PlatuneClient) Search(req *platune.SearchRequest) (*platune.SearchRespo
return nil, err
}

return searchClient.Recv()
res, err := searchClient.Recv()
if err == io.EOF {
p.ResetStreams()
res, err = searchClient.Recv()
}
return res, err
}

func (p *PlatuneClient) Lookup(
Expand Down

0 comments on commit f42f8fa

Please sign in to comment.