cleanup: remove getPath

The getPath call is only used once. Getting rid of it makes it easier to
understand.

Signed-off-by: Kun Yi <kunyi731@gmail.com>
Change-Id: Ifc8859f5fc68bb594003a6db7f7e80b1c1dfed28
diff --git a/manager.cpp b/manager.cpp
index 870bf60..64cc08f 100644
--- a/manager.cpp
+++ b/manager.cpp
@@ -27,17 +27,21 @@
 
 void BlobManager::eraseSession(GenericBlobInterface* handler, uint16_t session)
 {
-    /* Ok for openSessions[handler] to be an empty set */
-    openSessions[handler].erase(session);
-
-    auto path = getPath(session);
-    openFiles[path]--;
-    if (openFiles[path] == 0)
+    if (auto item = sessions.find(session); item != sessions.end())
     {
-        openFiles.erase(path);
+        const auto& blobId = item->second.blobId;
+
+        /* Ok for openSessions[handler] to be an empty set */
+        openSessions[handler].erase(session);
+        openFiles[blobId]--;
+        if (openFiles[blobId] == 0)
+        {
+            openFiles.erase(blobId);
+        }
+
+        /* Erase at the end after using the session info */
+        sessions.erase(session);
     }
-    /* Cannot erase before getPath() is called */
-    sessions.erase(session);
 }
 
 void BlobManager::cleanUpStaleSessions(GenericBlobInterface* handler)
@@ -183,16 +187,6 @@
     return nullptr;
 }
 
-std::string BlobManager::getPath(uint16_t session) const
-{
-    if (auto item = sessions.find(session); item != sessions.end())
-    {
-        return item->second.blobId;
-    }
-
-    return "";
-}
-
 bool BlobManager::stat(const std::string& path, BlobMeta* meta)
 {
     /* meta should never be NULL. */
diff --git a/manager.hpp b/manager.hpp
index 3097201..a7e9936 100644
--- a/manager.hpp
+++ b/manager.hpp
@@ -258,14 +258,6 @@
         uint16_t session,
         uint16_t requiredFlags = std::numeric_limits<uint16_t>::max());
 
-    /**
-     * Given a session id will return associated path.
-     *
-     * @param[in] session - the session.
-     * @return the path or "" on failure.
-     */
-    std::string getPath(uint16_t session) const;
-
   private:
     /* Helper method to erase a session from all maps */
     void eraseSession(GenericBlobInterface* handler, uint16_t session);