From e1c77841a76e71be09318caba599edddad367c58 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Sat, 25 Jul 2015 20:40:27 -0700 Subject: [PATCH] Fix a windows bug, also rename Remove to Delete --- cast-main.go | 8 ++++---- cp-main.go | 8 ++++---- session-main.go | 6 +++--- session-v2.go | 6 +++--- session_test.go | 5 ++++- 5 files changed, 18 insertions(+), 15 deletions(-) diff --git a/cast-main.go b/cast-main.go index fe8c5d4e..5f82384e 100644 --- a/cast-main.go +++ b/cast-main.go @@ -170,7 +170,7 @@ func doPrepareCastURLs(session *sessionV2, trapCh <-chan bool) { totalObjects++ case <-trapCh: session.Close() // If we are interrupted during the URL scanning, we drop the session. - session.Remove() + session.Delete() os.Exit(0) } } @@ -269,17 +269,17 @@ func runCastCmd(ctx *cli.Context) { session.Header.CommandType = "cast" session.Header.RootPath, err = os.Getwd() if err != nil { - session.Remove() + session.Delete() console.Fatalf("Unable to get current working folder. %s\n", err) } // extract URLs. session.Header.CommandArgs, err = args2URLs(ctx.Args()) if err != nil { - session.Remove() + session.Delete() console.Fatalf("One or more unknown URL types found in %s. %s\n", ctx.Args(), err) } doCastCmdSession(session) - session.Remove() + session.Delete() } diff --git a/cp-main.go b/cp-main.go index 4e6962f1..a8582b4a 100644 --- a/cp-main.go +++ b/cp-main.go @@ -171,7 +171,7 @@ func doPrepareCopyURLs(session *sessionV2, trapCh <-chan bool) { totalObjects++ case <-trapCh: session.Close() // If we are interrupted during the URL scanning, we drop the session. - session.Remove() + session.Delete() os.Exit(0) } } @@ -272,17 +272,17 @@ func runCopyCmd(ctx *cli.Context) { session.Header.CommandType = "cp" session.Header.RootPath, err = os.Getwd() if err != nil { - session.Remove() + session.Delete() console.Fatalf("Unable to get current working folder. %s\n", err) } // extract URLs. session.Header.CommandArgs, err = args2URLs(ctx.Args()) if err != nil { - session.Remove() + session.Delete() console.Fatalf("One or more unknown URL types found %s. %s\n", ctx.Args(), err) } doCopyCmdSession(session) - session.Remove() + session.Delete() } diff --git a/session-main.go b/session-main.go index 868181f9..8d735b1f 100644 --- a/session-main.go +++ b/session-main.go @@ -88,7 +88,7 @@ func clearSession(sid string) { if err != nil { console.Fatalf("Unable to load session ā€˜%s’, %s", sid, NewIodine(iodine.New(err, nil))) } - session.Remove() + session.Delete() } return } @@ -102,7 +102,7 @@ func clearSession(sid string) { console.Fatalf("Unable to load session ā€˜%s’, %s", sid, NewIodine(iodine.New(err, nil))) } if session != nil { - session.Remove() + session.Delete() } } @@ -170,7 +170,7 @@ func runSessionCmd(ctx *cli.Context) { if err != nil { console.Fatalf("Unable to close session file properly. %s\n", err) } - err = s.Remove() + err = s.Delete() if err != nil { console.Fatalf("Unable to clear session files properly. %s\n", err) } diff --git a/session-v2.go b/session-v2.go index fa958b48..21ce24e1 100644 --- a/session-v2.go +++ b/session-v2.go @@ -146,12 +146,12 @@ func (s *sessionV2) Close() error { return qs.Save(getSessionFile(s.SessionID)) } -// Remove removes all the session files. -func (s *sessionV2) Remove() error { +// Delete removes all the session files. +func (s *sessionV2) Delete() error { s.mutex.Lock() defer s.mutex.Unlock() - err := os.Remove(getSessionDataFile(s.SessionID)) + err := os.Remove(s.DataFP.Name()) if err != nil { return NewIodine(iodine.New(err, nil)) } diff --git a/session_test.go b/session_test.go index 4433047f..3dbe0af3 100644 --- a/session_test.go +++ b/session_test.go @@ -47,7 +47,10 @@ func (s *CmdTestSuite) TestSession(c *C) { c.Assert(err, IsNil) c.Assert(session.SessionID, Equals, savedSession.SessionID) - err = session.Remove() + err = savedSession.Close() + c.Assert(err, IsNil) + + err = savedSession.Delete() c.Assert(err, IsNil) }