added extra list view in own files.

This commit is contained in:
csoler 2018-09-27 13:42:49 +02:00
parent 359e11433b
commit 1383846364
No known key found for this signature in database
GPG key ID: 7BCA522266C0804C
9 changed files with 149 additions and 24 deletions

View file

@ -96,7 +96,7 @@ void ftExtraList::hashAFile()
FileDetails details;
{
RsStackMutex stack(extMutex);
RS_STACK_MUTEX(extMutex);
if (mToHash.empty())
return;
@ -116,7 +116,7 @@ void ftExtraList::hashAFile()
if (RsDirUtil::hashFile(details.info.path, details.info.fname,
details.info.hash, details.info.size))
{
RsStackMutex stack(extMutex);
RS_STACK_MUTEX(extMutex);
/* stick it in the available queue */
mFiles[details.info.hash] = details;
@ -146,7 +146,7 @@ bool ftExtraList::addExtraFile(std::string path, const RsFileHash& hash,
std::cerr << std::endl;
#endif
RsStackMutex stack(extMutex);
RS_STACK_MUTEX(extMutex);
FileDetails details;
@ -179,7 +179,7 @@ bool ftExtraList::removeExtraFile(const RsFileHash& hash, TransferRequestFlags f
std::cerr << std::endl;
#endif
RsStackMutex stack(extMutex);
RS_STACK_MUTEX(extMutex);
mHashOfHash.erase(makeEncryptedHash(hash)) ;
@ -230,7 +230,7 @@ bool ftExtraList::cleanupOldFiles()
std::cerr << std::endl;
#endif
RsStackMutex stack(extMutex);
RS_STACK_MUTEX(extMutex);
time_t now = time(NULL);
@ -286,7 +286,7 @@ bool ftExtraList::hashExtraFile(std::string path, uint32_t period, TransferRequ
#endif
/* add into queue */
RsStackMutex stack(extMutex);
RS_STACK_MUTEX(extMutex);
FileDetails details(path, period, flags);
details.info.age = time(NULL) + period;
@ -305,7 +305,7 @@ bool ftExtraList::hashExtraFileDone(std::string path, FileInfo &info)
RsFileHash hash;
{
/* Find in the path->hash map */
RsStackMutex stack(extMutex);
RS_STACK_MUTEX(extMutex);
std::map<std::string, RsFileHash>::iterator it;
if (mHashedList.end() == (it = mHashedList.find(path)))
@ -420,7 +420,7 @@ bool ftExtraList::saveList(bool &cleanup, std::list<RsItem *>& sList)
std::cerr << std::endl;
#endif
RsStackMutex stack(extMutex);
RS_STACK_MUTEX(extMutex);
std::map<RsFileHash, FileDetails>::const_iterator it;
@ -489,8 +489,8 @@ bool ftExtraList::loadList(std::list<RsItem *>& load)
/* add into system */
FileDetails file;
RsStackMutex stack(extMutex);
RS_STACK_MUTEX(extMutex);
FileDetails details;
details.info.path = fi->file.path;
@ -513,3 +513,12 @@ bool ftExtraList::loadList(std::list<RsItem *>& load)
return true;
}
void ftExtraList::getExtraFileList(std::vector<FileInfo>& files) const
{
RS_STACK_MUTEX(extMutex);
files.clear();
for(auto it(mFiles.begin());it!=mFiles.end();++it)
files.push_back(it->second.info);
}

View file

@ -137,6 +137,12 @@ public:
**/
virtual bool search(const RsFileHash &hash, FileSearchFlags hintflags, FileInfo &info) const;
/*!
* \brief getExtraFileList
* Retrieves the list for display purposes
*/
void getExtraFileList(std::vector<FileInfo>& files) const ;
/***
* Thread Main Loop
**/
@ -146,6 +152,7 @@ public:
* Configuration - store extra files.
*
**/
protected:
virtual RsSerialiser *setupSerialiser();
virtual bool saveList(bool &cleanup, std::list<RsItem*>&);

View file

@ -174,8 +174,11 @@ void ftServer::SetupFtServer()
void ftServer::connectToFileDatabase(p3FileDatabase *fdb)
{
mFileDatabase = fdb ;
mFtSearch->addSearchMode(fdb, RS_FILE_HINTS_LOCAL); // due to a bug in addSearchModule, modules can only be added one by one. Using | between flags wont work.
mFtSearch->addSearchMode(fdb, RS_FILE_HINTS_REMOTE);
mFileDatabase->setExtraList(mFtExtra);
}
void ftServer::connectToTurtleRouter(p3turtle *fts)
{