Skip to content

Commit

Permalink
session: Close data session file when migrating (#2126)
Browse files Browse the repository at this point in the history
Cleanup needed before removing the data file
  • Loading branch information
vadmeste authored and harshavardhana committed Apr 18, 2017
1 parent 9eb967c commit 656f4f1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 2 additions & 2 deletions cmd/session-main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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})
}
Expand All @@ -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})
}
}
Expand Down
3 changes: 3 additions & 0 deletions cmd/session-migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 656f4f1

Please sign in to comment.