mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-02-17 21:34:10 -05:00
added extra list view in own files.
This commit is contained in:
parent
359e11433b
commit
1383846364
@ -865,7 +865,7 @@ void InternalFileHierarchyStorage::print() const
|
|||||||
for(uint32_t i=0;i<mNodes.size();++i)
|
for(uint32_t i=0;i<mNodes.size();++i)
|
||||||
if(mNodes[i] == NULL)
|
if(mNodes[i] == NULL)
|
||||||
{
|
{
|
||||||
std::cerr << " Node " << i << ": empty " << std::endl;
|
//std::cerr << " Node " << i << ": empty " << std::endl;
|
||||||
++nempty ;
|
++nempty ;
|
||||||
}
|
}
|
||||||
else if(mNodes[i]->type() == FileStorageNode::TYPE_DIR)
|
else if(mNodes[i]->type() == FileStorageNode::TYPE_DIR)
|
||||||
@ -1183,6 +1183,11 @@ bool InternalFileHierarchyStorage::load(const std::string& fname)
|
|||||||
}
|
}
|
||||||
free(buffer) ;
|
free(buffer) ;
|
||||||
|
|
||||||
|
std::string err_str ;
|
||||||
|
|
||||||
|
if(!check(err_str))
|
||||||
|
std::cerr << "(EE) Error while loading file hierarchy " << fname << std::endl;
|
||||||
|
|
||||||
return true ;
|
return true ;
|
||||||
}
|
}
|
||||||
catch(read_error& e)
|
catch(read_error& e)
|
||||||
|
@ -25,6 +25,7 @@ static const uint32_t DELAY_BETWEEN_DIRECTORY_UPDATES = 600 ; // 10 m
|
|||||||
static const uint32_t DELAY_BETWEEN_REMOTE_DIRECTORY_SYNC_REQ = 120 ; // 2 minutes
|
static const uint32_t DELAY_BETWEEN_REMOTE_DIRECTORY_SYNC_REQ = 120 ; // 2 minutes
|
||||||
static const uint32_t DELAY_BETWEEN_LOCAL_DIRECTORIES_TS_UPDATE = 20 ; // 20 sec. But we only update for real if something has changed.
|
static const uint32_t DELAY_BETWEEN_LOCAL_DIRECTORIES_TS_UPDATE = 20 ; // 20 sec. But we only update for real if something has changed.
|
||||||
static const uint32_t DELAY_BETWEEN_REMOTE_DIRECTORIES_SWEEP = 60 ; // 60 sec.
|
static const uint32_t DELAY_BETWEEN_REMOTE_DIRECTORIES_SWEEP = 60 ; // 60 sec.
|
||||||
|
static const uint32_t DELAY_BETWEEN_EXTRA_FILES_CACHE_UPDATES = 2 ; // 2 sec.
|
||||||
|
|
||||||
static const uint32_t DELAY_BEFORE_DELETE_NON_EMPTY_REMOTE_DIR = 60*24*86400 ; // delete non empty remoe directories after 60 days of inactivity
|
static const uint32_t DELAY_BEFORE_DELETE_NON_EMPTY_REMOTE_DIR = 60*24*86400 ; // delete non empty remoe directories after 60 days of inactivity
|
||||||
static const uint32_t DELAY_BEFORE_DELETE_EMPTY_REMOTE_DIR = 5*24*86400 ; // delete empty remote directories after 5 days of inactivity
|
static const uint32_t DELAY_BEFORE_DELETE_EMPTY_REMOTE_DIR = 5*24*86400 ; // delete empty remote directories after 5 days of inactivity
|
||||||
|
@ -38,6 +38,7 @@
|
|||||||
|
|
||||||
//#define DEBUG_P3FILELISTS 1
|
//#define DEBUG_P3FILELISTS 1
|
||||||
#define DEBUG_CONTENT_FILTERING 1
|
#define DEBUG_CONTENT_FILTERING 1
|
||||||
|
#define DEBUG_FILE_HIERARCHY 1
|
||||||
|
|
||||||
static const uint32_t P3FILELISTS_UPDATE_FLAG_NOTHING_CHANGED = 0x0000 ;
|
static const uint32_t P3FILELISTS_UPDATE_FLAG_NOTHING_CHANGED = 0x0000 ;
|
||||||
static const uint32_t P3FILELISTS_UPDATE_FLAG_REMOTE_MAP_CHANGED = 0x0001 ;
|
static const uint32_t P3FILELISTS_UPDATE_FLAG_REMOTE_MAP_CHANGED = 0x0001 ;
|
||||||
@ -71,6 +72,7 @@ p3FileDatabase::p3FileDatabase(p3ServiceControl *mpeers)
|
|||||||
|
|
||||||
mUpdateFlags = P3FILELISTS_UPDATE_FLAG_NOTHING_CHANGED ;
|
mUpdateFlags = P3FILELISTS_UPDATE_FLAG_NOTHING_CHANGED ;
|
||||||
mLastRemoteDirSweepTS = 0 ;
|
mLastRemoteDirSweepTS = 0 ;
|
||||||
|
mLastExtraFilesCacheUpdate = 0;
|
||||||
mLastCleanupTime = 0 ;
|
mLastCleanupTime = 0 ;
|
||||||
mLastDataRecvTS = 0 ;
|
mLastDataRecvTS = 0 ;
|
||||||
mTrustFriendNodesForBannedFiles = TRUST_FRIEND_NODES_FOR_BANNED_FILES_DEFAULT;
|
mTrustFriendNodesForBannedFiles = TRUST_FRIEND_NODES_FOR_BANNED_FILES_DEFAULT;
|
||||||
@ -884,6 +886,8 @@ void p3FileDatabase::requestDirUpdate(void *ref)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Finds the pointer to the sub-element #row under element ref.
|
||||||
|
|
||||||
bool p3FileDatabase::findChildPointer( void *ref, int row, void *& result,
|
bool p3FileDatabase::findChildPointer( void *ref, int row, void *& result,
|
||||||
FileSearchFlags flags ) const
|
FileSearchFlags flags ) const
|
||||||
{
|
{
|
||||||
@ -891,10 +895,10 @@ bool p3FileDatabase::findChildPointer( void *ref, int row, void *& result,
|
|||||||
{
|
{
|
||||||
if(flags & RS_FILE_HINTS_LOCAL)
|
if(flags & RS_FILE_HINTS_LOCAL)
|
||||||
{
|
{
|
||||||
if(row != 0)
|
if(row != 0 && row != 1)
|
||||||
return false ;
|
return false ;
|
||||||
|
|
||||||
convertEntryIndexToPointer<sizeof(void*)>(0,0,result);
|
convertEntryIndexToPointer<sizeof(void*)>(0,row,result);
|
||||||
|
|
||||||
return true ;
|
return true ;
|
||||||
}
|
}
|
||||||
@ -913,12 +917,18 @@ bool p3FileDatabase::findChildPointer( void *ref, int row, void *& result,
|
|||||||
convertPointerToEntryIndex<sizeof(void*)>(ref,e,fi);
|
convertPointerToEntryIndex<sizeof(void*)>(ref,e,fi);
|
||||||
|
|
||||||
// check consistency
|
// check consistency
|
||||||
if( (fi == 0 && !(flags & RS_FILE_HINTS_LOCAL)) || (fi > 0 && (flags & RS_FILE_HINTS_LOCAL)))
|
if( (fi == 0 && !(flags & RS_FILE_HINTS_LOCAL)) || (fi > 1 && (flags & RS_FILE_HINTS_LOCAL)))
|
||||||
{
|
{
|
||||||
P3FILELISTS_ERROR() << "(EE) remote request on local index or local request on remote index. This should not happen." << std::endl;
|
P3FILELISTS_ERROR() << "(EE) remote request on local index or local request on remote index. This should not happen." << std::endl;
|
||||||
return false ;
|
return false ;
|
||||||
}
|
}
|
||||||
DirectoryStorage *storage = (fi==0)? ((DirectoryStorage*)mLocalSharedDirs) : ((DirectoryStorage*)mRemoteDirectories[fi-1]);
|
|
||||||
|
if(fi==1 && (flags & RS_FILE_HINTS_LOCAL)) // extra list
|
||||||
|
{
|
||||||
|
convertEntryIndexToPointer<sizeof(void*)>(row+1,1,result);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
DirectoryStorage *storage = (flags & RS_FILE_HINTS_LOCAL)? ((DirectoryStorage*)mLocalSharedDirs) : ((DirectoryStorage*)mRemoteDirectories[fi-1]);
|
||||||
|
|
||||||
// Case where the index is the top of a single person. Can be us, or a friend.
|
// Case where the index is the top of a single person. Can be us, or a friend.
|
||||||
|
|
||||||
@ -950,6 +960,65 @@ int p3FileDatabase::getSharedDirStatistics(const RsPeerId& pid,SharedDirStats& s
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void p3FileDatabase::getExtraFilesDirDetails(void *ref,DirectoryStorage::EntryIndex e,DirDetails& d) const
|
||||||
|
{
|
||||||
|
// update the cache of extra files if last requested too long ago
|
||||||
|
|
||||||
|
time_t now = time(NULL);
|
||||||
|
|
||||||
|
if(mLastExtraFilesCacheUpdate + DELAY_BETWEEN_EXTRA_FILES_CACHE_UPDATES <= now)
|
||||||
|
{
|
||||||
|
mExtraFiles->getExtraFileList(mExtraFilesCache);
|
||||||
|
mLastExtraFilesCacheUpdate = now;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
|
||||||
|
if(e == 0) // "virtual extra files directory" => create a dir with as many child as they are extra files
|
||||||
|
{
|
||||||
|
d.parent = NULL ;
|
||||||
|
|
||||||
|
d.prow = 0;//fi-1 ;
|
||||||
|
d.type = DIR_TYPE_DIR;
|
||||||
|
d.hash.clear() ;
|
||||||
|
d.count = mExtraFilesCache.size();
|
||||||
|
d.max_mtime = time(NULL);
|
||||||
|
d.mtime = time(NULL);
|
||||||
|
d.name = "Temporary shared files";
|
||||||
|
d.path = "/";
|
||||||
|
d.ref = ref ;
|
||||||
|
|
||||||
|
for(uint32_t i=0;i<mExtraFilesCache.size();++i)
|
||||||
|
{
|
||||||
|
DirStub stub;
|
||||||
|
stub.type = DIR_TYPE_FILE;
|
||||||
|
stub.name = mExtraFilesCache[i].fname;
|
||||||
|
convertEntryIndexToPointer<sizeof(void*)>(i,1,stub.ref); // local shared files from extra list
|
||||||
|
|
||||||
|
d.children.push_back(stub);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else // extra file. Just query the corresponding data from ftExtra
|
||||||
|
{
|
||||||
|
d.prow = 1;//fi-1 ;
|
||||||
|
d.type = DIR_TYPE_FILE;
|
||||||
|
|
||||||
|
FileInfo& f(mExtraFilesCache[(int)e-1]) ;
|
||||||
|
|
||||||
|
d.hash = f.hash;
|
||||||
|
d.count = 0;
|
||||||
|
d.max_mtime = time(NULL);
|
||||||
|
d.mtime = time(NULL);
|
||||||
|
d.name = f.fname;
|
||||||
|
d.path = "/";
|
||||||
|
d.ref = ref ;
|
||||||
|
|
||||||
|
convertEntryIndexToPointer<sizeof(void*)>(0,1,d.parent) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
d.id = RsPeerId();
|
||||||
|
}
|
||||||
|
|
||||||
// This function converts a pointer into directory details, to be used by the AbstractItemModel for browsing the files.
|
// This function converts a pointer into directory details, to be used by the AbstractItemModel for browsing the files.
|
||||||
int p3FileDatabase::RequestDirDetails(void *ref, DirDetails& d, FileSearchFlags flags) const
|
int p3FileDatabase::RequestDirDetails(void *ref, DirDetails& d, FileSearchFlags flags) const
|
||||||
{
|
{
|
||||||
@ -975,10 +1044,8 @@ int p3FileDatabase::RequestDirDetails(void *ref, DirDetails& d, FileSearchFlags
|
|||||||
{
|
{
|
||||||
d.ref = NULL ;
|
d.ref = NULL ;
|
||||||
d.type = DIR_TYPE_ROOT;
|
d.type = DIR_TYPE_ROOT;
|
||||||
d.count = 1;
|
|
||||||
d.parent = NULL;
|
d.parent = NULL;
|
||||||
d.prow = -1;
|
d.prow = -1;
|
||||||
d.ref = NULL;
|
|
||||||
d.name = "root";
|
d.name = "root";
|
||||||
d.hash.clear() ;
|
d.hash.clear() ;
|
||||||
d.path = "";
|
d.path = "";
|
||||||
@ -989,13 +1056,26 @@ int p3FileDatabase::RequestDirDetails(void *ref, DirDetails& d, FileSearchFlags
|
|||||||
if(flags & RS_FILE_HINTS_LOCAL)
|
if(flags & RS_FILE_HINTS_LOCAL)
|
||||||
{
|
{
|
||||||
void *p;
|
void *p;
|
||||||
convertEntryIndexToPointer<sizeof(void*)>(0,0,p);
|
|
||||||
|
|
||||||
|
{
|
||||||
|
convertEntryIndexToPointer<sizeof(void*)>(0,0,p); // root of own directories
|
||||||
DirStub stub;
|
DirStub stub;
|
||||||
stub.type = DIR_TYPE_PERSON;
|
stub.type = DIR_TYPE_PERSON;
|
||||||
stub.name = mServCtrl->getOwnId().toStdString();
|
stub.name = mServCtrl->getOwnId().toStdString();
|
||||||
stub.ref = p;
|
stub.ref = p;
|
||||||
d.children.push_back(stub);
|
d.children.push_back(stub);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
convertEntryIndexToPointer<sizeof(void*)>(0,1,p); // local shared files from extra list
|
||||||
|
DirStub stub;
|
||||||
|
stub.type = DIR_TYPE_PERSON;
|
||||||
|
stub.name = "Temporary shared files";
|
||||||
|
stub.ref = p;
|
||||||
|
|
||||||
|
d.children.push_back(stub);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else for(uint32_t i=0;i<mRemoteDirectories.size();++i)
|
else for(uint32_t i=0;i<mRemoteDirectories.size();++i)
|
||||||
if(mRemoteDirectories[i] != NULL)
|
if(mRemoteDirectories[i] != NULL)
|
||||||
@ -1014,6 +1094,7 @@ int p3FileDatabase::RequestDirDetails(void *ref, DirDetails& d, FileSearchFlags
|
|||||||
|
|
||||||
#ifdef DEBUG_FILE_HIERARCHY
|
#ifdef DEBUG_FILE_HIERARCHY
|
||||||
P3FILELISTS_DEBUG() << "ExtractData: ref=" << ref << ", flags=" << flags << " : returning this: " << std::endl;
|
P3FILELISTS_DEBUG() << "ExtractData: ref=" << ref << ", flags=" << flags << " : returning this: " << std::endl;
|
||||||
|
P3FILELISTS_DEBUG() << d << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return true ;
|
return true ;
|
||||||
@ -1025,12 +1106,25 @@ int p3FileDatabase::RequestDirDetails(void *ref, DirDetails& d, FileSearchFlags
|
|||||||
convertPointerToEntryIndex<sizeof(void*)>(ref,e,fi);
|
convertPointerToEntryIndex<sizeof(void*)>(ref,e,fi);
|
||||||
|
|
||||||
// check consistency
|
// check consistency
|
||||||
if( (fi == 0 && !(flags & RS_FILE_HINTS_LOCAL)) || (fi > 0 && (flags & RS_FILE_HINTS_LOCAL)))
|
if( (fi == 0 && !(flags & RS_FILE_HINTS_LOCAL)) || (fi > 1 && (flags & RS_FILE_HINTS_LOCAL)))
|
||||||
{
|
{
|
||||||
P3FILELISTS_ERROR() << "(EE) remote request on local index or local request on remote index. This should not happen." << std::endl;
|
P3FILELISTS_ERROR() << "(EE) remote request on local index or local request on remote index. This should not happen." << std::endl;
|
||||||
return false ;
|
return false ;
|
||||||
}
|
}
|
||||||
DirectoryStorage *storage = (fi==0)? ((DirectoryStorage*)mLocalSharedDirs) : ((DirectoryStorage*)mRemoteDirectories[fi-1]);
|
|
||||||
|
if((flags & RS_FILE_HINTS_LOCAL) && fi == 1) // extra list
|
||||||
|
{
|
||||||
|
getExtraFilesDirDetails(ref,e,d);
|
||||||
|
|
||||||
|
#ifdef DEBUG_FILE_HIERARCHY
|
||||||
|
P3FILELISTS_DEBUG() << "ExtractData: ref=" << ref << ", flags=" << flags << " : returning this: " << std::endl;
|
||||||
|
P3FILELISTS_DEBUG() << d << std::endl;
|
||||||
|
#endif
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
DirectoryStorage *storage = (flags & RS_FILE_HINTS_LOCAL)? ((DirectoryStorage*)mLocalSharedDirs) : ((DirectoryStorage*)mRemoteDirectories[fi-1]);
|
||||||
|
|
||||||
// Case where the index is the top of a single person. Can be us, or a friend.
|
// Case where the index is the top of a single person. Can be us, or a friend.
|
||||||
|
|
||||||
|
@ -45,6 +45,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "ft/ftsearch.h"
|
#include "ft/ftsearch.h"
|
||||||
|
#include "ft/ftextralist.h"
|
||||||
#include "retroshare/rsfiles.h"
|
#include "retroshare/rsfiles.h"
|
||||||
#include "services/p3service.h"
|
#include "services/p3service.h"
|
||||||
|
|
||||||
@ -87,9 +88,10 @@ class p3FileDatabase: public p3Service, public p3Config, public ftSearch //, pub
|
|||||||
// [...] more to add here
|
// [...] more to add here
|
||||||
};
|
};
|
||||||
|
|
||||||
explicit p3FileDatabase(p3ServiceControl *mpeers) ;
|
explicit p3FileDatabase(p3ServiceControl *mpeers);
|
||||||
~p3FileDatabase();
|
~p3FileDatabase();
|
||||||
|
|
||||||
|
void setExtraList(ftExtraList *f) { mExtraFiles = f ; }
|
||||||
/*!
|
/*!
|
||||||
* \brief forceSyncWithPeers
|
* \brief forceSyncWithPeers
|
||||||
*
|
*
|
||||||
@ -169,6 +171,7 @@ class p3FileDatabase: public p3Service, public p3Config, public ftSearch //, pub
|
|||||||
bool hashingProcessPaused();
|
bool hashingProcessPaused();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
void getExtraFilesDirDetails(void *ref,DirectoryStorage::EntryIndex e,DirDetails& d) const;
|
||||||
|
|
||||||
int filterResults(const std::list<void*>& firesults,std::list<DirDetails>& results,FileSearchFlags flags,const RsPeerId& peer_id) const;
|
int filterResults(const std::list<void*>& firesults,std::list<DirDetails>& results,FileSearchFlags flags,const RsPeerId& peer_id) const;
|
||||||
std::string makeRemoteFileName(const RsPeerId& pid) const;
|
std::string makeRemoteFileName(const RsPeerId& pid) const;
|
||||||
@ -219,8 +222,8 @@ class p3FileDatabase: public p3Service, public p3Config, public ftSearch //, pub
|
|||||||
|
|
||||||
std::vector<RemoteDirectoryStorage *> mRemoteDirectories ;
|
std::vector<RemoteDirectoryStorage *> mRemoteDirectories ;
|
||||||
LocalDirectoryStorage *mLocalSharedDirs ;
|
LocalDirectoryStorage *mLocalSharedDirs ;
|
||||||
|
|
||||||
LocalDirectoryUpdater *mLocalDirWatcher ;
|
LocalDirectoryUpdater *mLocalDirWatcher ;
|
||||||
|
ftExtraList *mExtraFiles;
|
||||||
|
|
||||||
// utility functions to make/get a pointer out of an (EntryIndex,PeerId) pair. This is further documented in the .cc
|
// utility functions to make/get a pointer out of an (EntryIndex,PeerId) pair. This is further documented in the .cc
|
||||||
|
|
||||||
@ -268,6 +271,8 @@ class p3FileDatabase: public p3Service, public p3Config, public ftSearch //, pub
|
|||||||
std::map<RsFileHash,BannedFileEntry> mPrimaryBanList ; // primary list (user controlled) of files banned from FT search and forwarding. map<real hash, BannedFileEntry>
|
std::map<RsFileHash,BannedFileEntry> mPrimaryBanList ; // primary list (user controlled) of files banned from FT search and forwarding. map<real hash, BannedFileEntry>
|
||||||
std::map<RsPeerId,PeerBannedFilesEntry> mPeerBannedFiles ; // records of which files other peers ban, stored as H(H(f))
|
std::map<RsPeerId,PeerBannedFilesEntry> mPeerBannedFiles ; // records of which files other peers ban, stored as H(H(f))
|
||||||
std::set<RsFileHash> mBannedFileList ; // list of banned hashes. This include original hashs and H(H(f)) when coming from friends.
|
std::set<RsFileHash> mBannedFileList ; // list of banned hashes. This include original hashs and H(H(f)) when coming from friends.
|
||||||
|
mutable std::vector<FileInfo> mExtraFilesCache; // cache for extra files, to avoid requesting them too often.
|
||||||
|
mutable time_t mLastExtraFilesCacheUpdate ;
|
||||||
bool mTrustFriendNodesForBannedFiles ;
|
bool mTrustFriendNodesForBannedFiles ;
|
||||||
bool mBannedFileListNeedsUpdate;
|
bool mBannedFileListNeedsUpdate;
|
||||||
time_t mLastPrimaryBanListChangeTimeStamp;
|
time_t mLastPrimaryBanListChangeTimeStamp;
|
||||||
|
@ -96,7 +96,7 @@ void ftExtraList::hashAFile()
|
|||||||
FileDetails details;
|
FileDetails details;
|
||||||
|
|
||||||
{
|
{
|
||||||
RsStackMutex stack(extMutex);
|
RS_STACK_MUTEX(extMutex);
|
||||||
|
|
||||||
if (mToHash.empty())
|
if (mToHash.empty())
|
||||||
return;
|
return;
|
||||||
@ -116,7 +116,7 @@ void ftExtraList::hashAFile()
|
|||||||
if (RsDirUtil::hashFile(details.info.path, details.info.fname,
|
if (RsDirUtil::hashFile(details.info.path, details.info.fname,
|
||||||
details.info.hash, details.info.size))
|
details.info.hash, details.info.size))
|
||||||
{
|
{
|
||||||
RsStackMutex stack(extMutex);
|
RS_STACK_MUTEX(extMutex);
|
||||||
|
|
||||||
/* stick it in the available queue */
|
/* stick it in the available queue */
|
||||||
mFiles[details.info.hash] = details;
|
mFiles[details.info.hash] = details;
|
||||||
@ -146,7 +146,7 @@ bool ftExtraList::addExtraFile(std::string path, const RsFileHash& hash,
|
|||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
RsStackMutex stack(extMutex);
|
RS_STACK_MUTEX(extMutex);
|
||||||
|
|
||||||
FileDetails details;
|
FileDetails details;
|
||||||
|
|
||||||
@ -179,7 +179,7 @@ bool ftExtraList::removeExtraFile(const RsFileHash& hash, TransferRequestFlags f
|
|||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
RsStackMutex stack(extMutex);
|
RS_STACK_MUTEX(extMutex);
|
||||||
|
|
||||||
mHashOfHash.erase(makeEncryptedHash(hash)) ;
|
mHashOfHash.erase(makeEncryptedHash(hash)) ;
|
||||||
|
|
||||||
@ -230,7 +230,7 @@ bool ftExtraList::cleanupOldFiles()
|
|||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
RsStackMutex stack(extMutex);
|
RS_STACK_MUTEX(extMutex);
|
||||||
|
|
||||||
time_t now = time(NULL);
|
time_t now = time(NULL);
|
||||||
|
|
||||||
@ -286,7 +286,7 @@ bool ftExtraList::hashExtraFile(std::string path, uint32_t period, TransferRequ
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* add into queue */
|
/* add into queue */
|
||||||
RsStackMutex stack(extMutex);
|
RS_STACK_MUTEX(extMutex);
|
||||||
|
|
||||||
FileDetails details(path, period, flags);
|
FileDetails details(path, period, flags);
|
||||||
details.info.age = time(NULL) + period;
|
details.info.age = time(NULL) + period;
|
||||||
@ -305,7 +305,7 @@ bool ftExtraList::hashExtraFileDone(std::string path, FileInfo &info)
|
|||||||
RsFileHash hash;
|
RsFileHash hash;
|
||||||
{
|
{
|
||||||
/* Find in the path->hash map */
|
/* Find in the path->hash map */
|
||||||
RsStackMutex stack(extMutex);
|
RS_STACK_MUTEX(extMutex);
|
||||||
|
|
||||||
std::map<std::string, RsFileHash>::iterator it;
|
std::map<std::string, RsFileHash>::iterator it;
|
||||||
if (mHashedList.end() == (it = mHashedList.find(path)))
|
if (mHashedList.end() == (it = mHashedList.find(path)))
|
||||||
@ -420,7 +420,7 @@ bool ftExtraList::saveList(bool &cleanup, std::list<RsItem *>& sList)
|
|||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
RsStackMutex stack(extMutex);
|
RS_STACK_MUTEX(extMutex);
|
||||||
|
|
||||||
|
|
||||||
std::map<RsFileHash, FileDetails>::const_iterator it;
|
std::map<RsFileHash, FileDetails>::const_iterator it;
|
||||||
@ -489,8 +489,8 @@ bool ftExtraList::loadList(std::list<RsItem *>& load)
|
|||||||
/* add into system */
|
/* add into system */
|
||||||
FileDetails file;
|
FileDetails file;
|
||||||
|
|
||||||
RsStackMutex stack(extMutex);
|
RS_STACK_MUTEX(extMutex);
|
||||||
|
|
||||||
FileDetails details;
|
FileDetails details;
|
||||||
|
|
||||||
details.info.path = fi->file.path;
|
details.info.path = fi->file.path;
|
||||||
@ -513,3 +513,12 @@ bool ftExtraList::loadList(std::list<RsItem *>& load)
|
|||||||
return true;
|
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);
|
||||||
|
}
|
||||||
|
@ -137,6 +137,12 @@ public:
|
|||||||
**/
|
**/
|
||||||
virtual bool search(const RsFileHash &hash, FileSearchFlags hintflags, FileInfo &info) const;
|
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
|
* Thread Main Loop
|
||||||
**/
|
**/
|
||||||
@ -146,6 +152,7 @@ public:
|
|||||||
* Configuration - store extra files.
|
* Configuration - store extra files.
|
||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual RsSerialiser *setupSerialiser();
|
virtual RsSerialiser *setupSerialiser();
|
||||||
virtual bool saveList(bool &cleanup, std::list<RsItem*>&);
|
virtual bool saveList(bool &cleanup, std::list<RsItem*>&);
|
||||||
|
@ -174,8 +174,11 @@ void ftServer::SetupFtServer()
|
|||||||
void ftServer::connectToFileDatabase(p3FileDatabase *fdb)
|
void ftServer::connectToFileDatabase(p3FileDatabase *fdb)
|
||||||
{
|
{
|
||||||
mFileDatabase = 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_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);
|
mFtSearch->addSearchMode(fdb, RS_FILE_HINTS_REMOTE);
|
||||||
|
|
||||||
|
mFileDatabase->setExtraList(mFtExtra);
|
||||||
}
|
}
|
||||||
void ftServer::connectToTurtleRouter(p3turtle *fts)
|
void ftServer::connectToTurtleRouter(p3turtle *fts)
|
||||||
{
|
{
|
||||||
|
@ -160,6 +160,7 @@ struct PeerBandwidthLimits : RsSerializable
|
|||||||
#define DIR_TYPE_PERSON 0x02
|
#define DIR_TYPE_PERSON 0x02
|
||||||
#define DIR_TYPE_DIR 0x04
|
#define DIR_TYPE_DIR 0x04
|
||||||
#define DIR_TYPE_FILE 0x08
|
#define DIR_TYPE_FILE 0x08
|
||||||
|
#define DIR_TYPE_EXTRA 0x10
|
||||||
|
|
||||||
/* flags for Directry request -
|
/* flags for Directry request -
|
||||||
* two types;
|
* two types;
|
||||||
|
@ -1158,9 +1158,9 @@ void FlatStyle_RDM::postMods()
|
|||||||
|
|
||||||
bool RetroshareDirModel::requestDirDetails(void *ref, bool remote,DirDetails& d) const
|
bool RetroshareDirModel::requestDirDetails(void *ref, bool remote,DirDetails& d) const
|
||||||
{
|
{
|
||||||
#ifdef RDM_DEBUG
|
//#ifdef RDM_DEBUG
|
||||||
std::cerr << "RequestDirDetails:: ref = " << ref << ", remote=" << remote << std::endl;
|
std::cerr << "RequestDirDetails:: ref = " << ref << ", remote=" << remote << std::endl;
|
||||||
#endif
|
//#endif
|
||||||
|
|
||||||
// We look in cache and re-use the last result if the reference and remote are the same.
|
// We look in cache and re-use the last result if the reference and remote are the same.
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user