added p3fileDatabase as a service in rsinit

This commit is contained in:
mr-alice 2016-08-13 10:15:02 +02:00
parent df14b41ba6
commit 2668b6da1c
6 changed files with 27 additions and 13 deletions

View File

@ -100,7 +100,10 @@ class InternalFileHierarchyStorage
for(uint32_t i=0;i<d.subdirs.size();) for(uint32_t i=0;i<d.subdirs.size();)
if(subdirs.find(static_cast<DirEntry*>(mNodes[d.subdirs[i]])->dir_name) == subdirs.end()) if(subdirs.find(static_cast<DirEntry*>(mNodes[d.subdirs[i]])->dir_name) == subdirs.end())
removeDirectory(d.subdirs[i]) ; {
if( !removeDirectory(d.subdirs[i]))
i++ ;
}
else else
{ {
should_create.erase(static_cast<DirEntry*>(mNodes[d.subdirs[i]])->dir_name) ; should_create.erase(static_cast<DirEntry*>(mNodes[d.subdirs[i]])->dir_name) ;

View File

@ -125,6 +125,7 @@ public:
virtual bool extractData(const EntryIndex& indx,DirDetails& d) virtual bool extractData(const EntryIndex& indx,DirDetails& d)
{ {
NOT_IMPLEMENTED(); NOT_IMPLEMENTED();
return false;
} }
}; };

View File

@ -105,7 +105,7 @@ int p3FileDatabase::tick()
static time_t last_print_time = 0; static time_t last_print_time = 0;
time_t now = time(NULL) ; time_t now = time(NULL) ;
if(last_print_time + 60 < now) if(last_print_time + 20 < now)
{ {
mLocalSharedDirs->print(); mLocalSharedDirs->print();
last_print_time = now ; last_print_time = now ;
@ -212,6 +212,10 @@ void p3FileDatabase::cleanup()
mDirectories.push_back(NULL) ; mDirectories.push_back(NULL) ;
mDirectories[i] = new RemoteDirectoryStorage(*it,makeRemoteFileName(*it)); mDirectories[i] = new RemoteDirectoryStorage(*it,makeRemoteFileName(*it));
if(mFriendIndexTab.size() <= i)
mFriendIndexTab.resize(i+1) ;
mFriendIndexTab[i] = *it ; mFriendIndexTab[i] = *it ;
mFriendIndexMap[*it] = i; mFriendIndexMap[*it] = i;

View File

@ -148,19 +148,19 @@ void ftServer::SetupFtServer()
mFtController->setPartialsDirectory(tmppath); mFtController->setPartialsDirectory(tmppath);
mFtController->setDownloadDirectory(tmppath); mFtController->setDownloadDirectory(tmppath);
/* Make Cache Source/Store */
mFileDatabase = new p3FileDatabase(mServiceCtrl) ;
/* complete search setup */ /* complete search setup */
mFtSearch->addSearchMode(mFtExtra, RS_FILE_HINTS_EXTRA); mFtSearch->addSearchMode(mFtExtra, RS_FILE_HINTS_EXTRA);
mFtSearch->addSearchMode(mFileDatabase, RS_FILE_HINTS_LOCAL | RS_FILE_HINTS_REMOTE);
mServiceCtrl->registerServiceMonitor(mFtController, getServiceInfo().mServiceType); mServiceCtrl->registerServiceMonitor(mFtController, getServiceInfo().mServiceType);
return; return;
} }
void ftServer::connectToFileDatabase(p3FileDatabase *fdb)
{
mFileDatabase = fdb ;
mFtSearch->addSearchMode(fdb, RS_FILE_HINTS_LOCAL | RS_FILE_HINTS_REMOTE);
}
void ftServer::connectToTurtleRouter(p3turtle *fts) void ftServer::connectToTurtleRouter(p3turtle *fts)
{ {
mTurtleRouter = fts ; mTurtleRouter = fts ;

View File

@ -53,6 +53,7 @@
#include "pqi/p3cfgmgr.h" #include "pqi/p3cfgmgr.h"
class p3ConnectMgr; class p3ConnectMgr;
class p3FileDatabase;
class CacheStrapper; class CacheStrapper;
class CacheTransfer; class CacheTransfer;
@ -94,7 +95,8 @@ public:
/* Final Setup (once everything is assigned) */ /* Final Setup (once everything is assigned) */
void SetupFtServer() ; void SetupFtServer() ;
virtual void connectToTurtleRouter(p3turtle *p) ; virtual void connectToTurtleRouter(p3turtle *p) ;
virtual void connectToFileDatabase(p3FileDatabase *b);
// Implements RsTurtleClientService // Implements RsTurtleClientService
// //

View File

@ -56,7 +56,8 @@
#include <openssl/rand.h> #include <openssl/rand.h>
#include <fcntl.h> #include <fcntl.h>
#include <gxstunnel/p3gxstunnel.h> #include "gxstunnel/p3gxstunnel.h"
#include "file_sharing/p3filelists.h"
#define ENABLE_GROUTER #define ENABLE_GROUTER
@ -1481,22 +1482,25 @@ int RsServer::StartupRetroShare()
pqih->addService(gr,true) ; pqih->addService(gr,true) ;
#endif #endif
p3turtle *tr = new p3turtle(serviceCtrl,mLinkMgr) ; p3FileDatabase *fdb = new p3FileDatabase(serviceCtrl) ;
p3turtle *tr = new p3turtle(serviceCtrl,mLinkMgr) ;
rsTurtle = tr ; rsTurtle = tr ;
pqih -> addService(tr,true); pqih -> addService(tr,true);
pqih -> addService(ftserver,true); pqih -> addService(fdb,true);
pqih -> addService(ftserver,true);
mGxsTunnels = new p3GxsTunnelService(mGxsIdService) ; mGxsTunnels = new p3GxsTunnelService(mGxsIdService) ;
mGxsTunnels->connectToTurtleRouter(tr) ; mGxsTunnels->connectToTurtleRouter(tr) ;
rsGxsTunnel = mGxsTunnels; rsGxsTunnel = mGxsTunnels;
rsDisc = mDisc; rsDisc = mDisc;
rsMsgs = new p3Msgs(msgSrv, chatSrv); rsMsgs = new p3Msgs(msgSrv, chatSrv);
// connect components to turtle router. // connect components to turtle router.
ftserver->connectToTurtleRouter(tr) ; ftserver->connectToTurtleRouter(tr) ;
chatSrv->connectToGxsTunnelService(mGxsTunnels) ; ftserver->connectToFileDatabase(fdb) ;
chatSrv->connectToGxsTunnelService(mGxsTunnels) ;
gr->connectToTurtleRouter(tr) ; gr->connectToTurtleRouter(tr) ;
#ifdef ENABLE_GROUTER #ifdef ENABLE_GROUTER
msgSrv->connectToGlobalRouter(gr) ; msgSrv->connectToGlobalRouter(gr) ;