From fadb997b0176d8132e59f48c351220793f3a079f Mon Sep 17 00:00:00 2001 From: ale <ale@incal.net> Date: Tue, 13 Jan 2015 14:01:04 +0000 Subject: [PATCH] mountExists should not crash on GetMount failure --- cmd/radioctl/radioctl.go | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/cmd/radioctl/radioctl.go b/cmd/radioctl/radioctl.go index 233d274b..2325cdb4 100644 --- a/cmd/radioctl/radioctl.go +++ b/cmd/radioctl/radioctl.go @@ -109,10 +109,7 @@ func addEncodingFlags(f *gonutsflag.FlagSet, p *autoradio.EncodingParams) { } func mountExists(name string, client *autoradio.Client) bool { - m, err := client.GetMount(name) - if err != nil { - log.Fatal(err) - } + m, _ := client.GetMount(name) return m != nil } @@ -155,7 +152,7 @@ func (cmd *createMountCommand) Run(args []string) { // Check if the mount already exists. client := getClient() - if oldm, _ := client.GetMount(path); oldm != nil { + if mountExists(path, client) { log.Fatal("ERROR: A mount with that name already exists!") } @@ -190,7 +187,7 @@ func newCreateTranscodingMountCommand() *createTranscodingMountCommand { Short: "Create a transcoded mount", Long: ` Create a new stream that will transcode the parent stream with -different encoding parameters. +different encoding parameters. `, }, params: &autoradio.EncodingParams{}, @@ -425,15 +422,16 @@ func (cmd *showMountCommand) Run(args []string) { if len(args) != 1 { log.Fatal("Wrong number of arguments") } - mount, err := getClient().GetMount(args[0]) + + m, err := getClient().GetMount(args[0]) if err != nil { log.Fatalf("ERROR: %v", err) } - if mount == nil { + if m == nil { log.Fatal("ERROR: mount not found") } - printMount(mount) + printMount(m) } var cmdr = &commander.Command{ -- GitLab