From 2623eeb82ef68b634a472e308e17e63aff4dc5a4 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Mon, 29 Feb 2016 01:24:42 -0800 Subject: [PATCH] session: Remove session backup file if any. Fixes #1623 --- .travis.yml | 1 + buildscripts/checkgopath.sh | 5 +++++ session-v6.go | 6 ++++++ 3 files changed, 12 insertions(+) diff --git a/.travis.yml b/.travis.yml index 578a0f02..4eeb1d34 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,6 +16,7 @@ go: - 1.6 script: +- make - diff -au <(gofmt -d *.go) <(printf "") - diff -au <(gofmt -d pkg) <(printf "") diff --git a/buildscripts/checkgopath.sh b/buildscripts/checkgopath.sh index 167be6bd..5f964fbc 100644 --- a/buildscripts/checkgopath.sh +++ b/buildscripts/checkgopath.sh @@ -15,6 +15,11 @@ # limitations under the License. # +## use a portable implementation here `realpath` doesn't exist on Darwin/OS X. +realpath() { + [[ $1 = /* ]] && echo "$1" || echo "$PWD/${1#./}" +} + _init() { shopt -s extglob diff --git a/session-v6.go b/session-v6.go index 97aaf854..b095816f 100644 --- a/session-v6.go +++ b/session-v6.go @@ -300,20 +300,26 @@ func (s *sessionV6) Delete() *probe.Error { // the file is closed already s.DataFP.Close() + // Remove the data file. if e := os.Remove(name); e != nil { return probe.NewError(e) } } + // Fetch the session file. sessionFile, err := getSessionFile(s.SessionID) if err != nil { return err.Trace(s.SessionID) } + // Remove session file if e := os.Remove(sessionFile); e != nil { return probe.NewError(e) } + // Remove session backup file if any, ignore any error. + os.Remove(sessionFile + ".old") + return nil }