From 656f4f13d0e8e75f3719a8d778c1a9af782eafdf Mon Sep 17 00:00:00 2001 From: Anis Elleuch Date: Tue, 18 Apr 2017 20:37:54 +0100 Subject: [PATCH] session: Close data session file when migrating (#2126) Cleanup needed before removing the data file --- cmd/session-main.go | 4 ++-- cmd/session-migrate.go | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/cmd/session-main.go b/cmd/session-main.go index 7709c2c0..34ddaac8 100644 --- a/cmd/session-main.go +++ b/cmd/session-main.go @@ -134,7 +134,7 @@ func clearSession(sid string) { session, err := loadSessionV8(sid) fatalIf(err.Trace(sid), "Unable to load session `"+sid+"`.") - fatalIf(session.Delete().Trace(sid), "Unable to load session `"+sid+"`.") + fatalIf(session.Delete().Trace(sid), "Unable to remove session `"+sid+"`.") printMsg(clearSessionMessage{Status: "success", SessionID: sid}) } @@ -156,7 +156,7 @@ func clearSession(sid string) { } if session != nil { - fatalIf(session.Delete().Trace(sid), "Unable to load session `"+sid+"`.") + fatalIf(session.Delete().Trace(sid), "Unable to remove session `"+sid+"`.") printMsg(clearSessionMessage{Status: "success", SessionID: sid}) } } diff --git a/cmd/session-migrate.go b/cmd/session-migrate.go index dbc8fb55..4735bc55 100644 --- a/cmd/session-migrate.go +++ b/cmd/session-migrate.go @@ -37,6 +37,9 @@ func migrateSessionV7ToV8() { fatalIf(err.Trace(sid), "Unable to load version `7`. Migration failed please report this issue at https://github.com/minio/mc/issues.") } + // Close underlying session data file. + sV7.DataFP.Close() + sessionVersion, e := strconv.Atoi(sV7.Header.Version) fatalIf(probe.NewError(e), "Unable to load version `7`. Migration failed please report this issue at https://github.com/minio/mc/issues.") if sessionVersion > 7 { // It is new format.