From c253ad76a8fa4521887e4b3c5cc95bc4205e5e0f Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Sat, 25 Jul 2015 21:01:58 -0700 Subject: [PATCH] Fix session delete bug in doCopy and doCast session --- cast-main.go | 4 +++- cp-main.go | 4 +++- session-v2.go | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/cast-main.go b/cast-main.go index 5f82384e..57d2d0d7 100644 --- a/cast-main.go +++ b/cast-main.go @@ -263,12 +263,12 @@ func runCastCmd(ctx *cli.Context) { checkCastSyntax(ctx) session := newSessionV2() - defer session.Close() var err error session.Header.CommandType = "cast" session.Header.RootPath, err = os.Getwd() if err != nil { + session.Close() session.Delete() console.Fatalf("Unable to get current working folder. %s\n", err) } @@ -276,10 +276,12 @@ func runCastCmd(ctx *cli.Context) { // extract URLs. session.Header.CommandArgs, err = args2URLs(ctx.Args()) if err != nil { + session.Close() session.Delete() console.Fatalf("One or more unknown URL types found in %s. %s\n", ctx.Args(), err) } doCastCmdSession(session) + session.Close() session.Delete() } diff --git a/cp-main.go b/cp-main.go index a8582b4a..bcc42aab 100644 --- a/cp-main.go +++ b/cp-main.go @@ -266,12 +266,12 @@ func runCopyCmd(ctx *cli.Context) { checkCopySyntax(ctx) session := newSessionV2() - defer session.Close() var err error session.Header.CommandType = "cp" session.Header.RootPath, err = os.Getwd() if err != nil { + session.Close() session.Delete() console.Fatalf("Unable to get current working folder. %s\n", err) } @@ -279,10 +279,12 @@ func runCopyCmd(ctx *cli.Context) { // extract URLs. session.Header.CommandArgs, err = args2URLs(ctx.Args()) if err != nil { + session.Close() session.Delete() console.Fatalf("One or more unknown URL types found %s. %s\n", ctx.Args(), err) } doCopyCmdSession(session) + session.Close() session.Delete() } diff --git a/session-v2.go b/session-v2.go index 21ce24e1..f44cfabf 100644 --- a/session-v2.go +++ b/session-v2.go @@ -198,7 +198,7 @@ func loadSessionV2(sid string) (*sessionV2, error) { s.DataFP, err = os.Open(getSessionDataFile(s.SessionID)) if err != nil { - console.Fatalf("Unable to open session data file \""+getSessionDataFile(s.SessionID)+"\". %s", NewIodine(iodine.New(errNotConfigured{}, nil))) + console.Fatalf("Unable to open session data file \""+getSessionDataFile(s.SessionID)+"\". %s\n", NewIodine(iodine.New(err, nil))) } return s, nil