session: Remove session backup file if any.

Fixes #1623
This commit is contained in:
Harshavardhana
2016-02-29 02:06:25 -08:00
parent 614d6d81e5
commit 2623eeb82e
3 changed files with 12 additions and 0 deletions
+1
View File
@@ -16,6 +16,7 @@ go:
- 1.6
script:
- make
- diff -au <(gofmt -d *.go) <(printf "")
- diff -au <(gofmt -d pkg) <(printf "")
+5
View File
@@ -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
+6
View File
@@ -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
}