Don't refetch file that already exists in the local database
diff --git a/src/dispatcher.cc b/src/dispatcher.cc
index 5b4388e..1928912 100644
--- a/src/dispatcher.cc
+++ b/src/dispatcher.cc
@@ -268,16 +268,25 @@
 
       Name fileNameBase = Name (deviceName)("file")(hash.GetHash (), hash.GetHashBytes ());
 
-      if (m_objectDbMap.find (hash) == m_objectDbMap.end ())
+      string hashStr = lexical_cast<string> (hash);
+      if (ObjectDb::DoesExist (m_rootDir / ".chronoshare",  deviceName, hashStr))
         {
-          _LOG_DEBUG ("create ObjectDb for " << hash);
-          m_objectDbMap [hash] = make_shared<ObjectDb> (m_rootDir / ".chronoshare", lexical_cast<string> (hash));
+          _LOG_DEBUG ("File already exists in the database. No need to refetch, just directly applying the action");
+          Did_FetchManager_FileFetchComplete (deviceName, fileNameBase);
         }
+      else
+        {
+          if (m_objectDbMap.find (hash) == m_objectDbMap.end ())
+            {
+              _LOG_DEBUG ("create ObjectDb for " << hash);
+              m_objectDbMap [hash] = make_shared<ObjectDb> (m_rootDir / ".chronoshare", hashStr);
+            }
 
-      m_fileFetcher->Enqueue (deviceName, fileNameBase,
-                              bind (&Dispatcher::Did_FetchManager_FileSegmentFetch, this, _1, _2, _3, _4),
-                              bind (&Dispatcher::Did_FetchManager_FileFetchComplete, this, _1, _2),
-                              0, action->seg_num () - 1, FetchManager::PRIORITY_NORMAL);
+          m_fileFetcher->Enqueue (deviceName, fileNameBase,
+                                  bind (&Dispatcher::Did_FetchManager_FileSegmentFetch, this, _1, _2, _3, _4),
+                                  bind (&Dispatcher::Did_FetchManager_FileFetchComplete, this, _1, _2),
+                                  0, action->seg_num () - 1, FetchManager::PRIORITY_NORMAL);
+        }
     }
 }