From 1e346fc118fded28165ef69853a3890ffc1ab48b Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Fri, 25 Sep 2015 20:52:13 -0700 Subject: [PATCH] Print friendly message rather than fatalIf and exit cleanly. --- cp-main.go | 5 ++++- mirror-main.go | 5 ++++- session-v2.go | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/cp-main.go b/cp-main.go index 367a2d5a..34323670 100644 --- a/cp-main.go +++ b/cp-main.go @@ -261,7 +261,10 @@ func doCopyCmdSession(session *sessionV2) { console.Printf("%c[2K\n", 27) console.Printf("%c[A", 27) } - fatalIf(cpURLs.Error.Trace(), fmt.Sprintf("Failed to copy ‘%s’.", cpURLs.SourceContent.Name)) + errorIf(cpURLs.Error.Trace(), fmt.Sprintf("Failed to copy ‘%s’.", cpURLs.SourceContent.Name)) + session.Close() + session.Info() + os.Exit(0) } case <-trapCh: // Receive interrupt notification. // Print in new line and adjust to top so that we don't print over the ongoing progress bar diff --git a/mirror-main.go b/mirror-main.go index f71010c7..9712e59c 100644 --- a/mirror-main.go +++ b/mirror-main.go @@ -259,7 +259,10 @@ func doMirrorCmdSession(session *sessionV2) { console.Printf("%c[2K\n", 27) console.Printf("%c[A", 27) } - fatalIf(sURLs.Error.Trace(), "Failed to mirror.") + errorIf(sURLs.Error.Trace(), "Failed to mirror.") + session.Close() + session.Info() + os.Exit(0) } case <-trapCh: // Receive interrupt notification. // Print in new line and adjust to top so that we don't print over the ongoing progress bar diff --git a/session-v2.go b/session-v2.go index e15fb978..60ad4681 100644 --- a/session-v2.go +++ b/session-v2.go @@ -128,7 +128,7 @@ func newSessionV2() *sessionV2 { // String printer for SessionV2 func (s sessionV2) Info() { - console.Infoln("Session terminated. To resume session ‘mc session resume " + s.SessionID + "’") + console.Infoln("Session safely terminated. To resume session ‘mc session resume " + s.SessionID + "’") } // HasData provides true if this is a session resume, false otherwise.