For the first time dispatcher test is working... though there is still
some instability with sqlite3. Sometimes complains about "Library
routine called out of sequence" when writing...
diff --git a/src/dispatcher.cc b/src/dispatcher.cc
index 556144f..1775ca2 100644
--- a/src/dispatcher.cc
+++ b/src/dispatcher.cc
@@ -254,9 +254,11 @@
if (m_objectDbMap.find (hash) == m_objectDbMap.end ())
{
_LOG_DEBUG ("create ObjectDb for " << hash);
- m_objectDbMap [hash] = make_shared<ObjectDb> (m_rootDir, lexical_cast<string> (hash));
+ m_objectDbMap [hash] = make_shared<ObjectDb> (m_rootDir / ".chronoshare", lexical_cast<string> (hash));
}
+ _LOG_DEBUG ("dafaq: " << (m_objectDbMap.find (hash) == m_objectDbMap.end ()));
+
m_fileFetcher->Enqueue (deviceName, fileNameBase,
bind (&Dispatcher::Did_FetchManager_FileSegmentFetch, this, _1, _2, _3, _4),
bind (&Dispatcher::Did_FetchManager_FileFetchComplete, this, _1, _2),
@@ -325,6 +327,16 @@
const Bytes &hashBytes = fileBaseName.getCompFromBack (0);
Hash hash (head (hashBytes), hashBytes.size ());
+ if (m_objectDbMap.find (hash) != m_objectDbMap.end())
+ {
+ // remove the db handle
+ m_objectDbMap.erase (hash); // to commit write
+ }
+ else
+ {
+ _LOG_ERROR ("no db available for this file: " << hash);
+ }
+
FileItemsPtr filesToAssemble = m_actionLog->LookupFilesForHash (hash);
for (FileItems::iterator file = filesToAssemble->begin ();
@@ -337,14 +349,4 @@
last_write_time (filePath, file->mtime ());
permissions (filePath, static_cast<filesystem::perms> (file->mode ()));
}
-
- if (m_objectDbMap.find (hash) != m_objectDbMap.end())
- {
- // remove the db handle
- m_objectDbMap.erase (hash);
- }
- else
- {
- _LOG_ERROR ("no db available for this file: " << hash);
- }
}