mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
Merge pull request #601 from csoler/v0.6-FileListsOptim
removed unused updateHash() functions in directory_storage. Fixed a b…
This commit is contained in:
commit
31b1583c36
@ -160,19 +160,6 @@ void DirectoryStorage::locked_check()
|
|||||||
std::cerr << "Check error: " << error << std::endl;
|
std::cerr << "Check error: " << error << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DirectoryStorage::updateFile(const EntryIndex& index,const RsFileHash& hash,const std::string& fname, uint64_t size,time_t modf_time)
|
|
||||||
{
|
|
||||||
RS_STACK_MUTEX(mDirStorageMtx) ;
|
|
||||||
mChanged = true ;
|
|
||||||
return mFileHierarchy->updateFile(index,hash,fname,size,modf_time);
|
|
||||||
}
|
|
||||||
bool DirectoryStorage::updateHash(const EntryIndex& index,const RsFileHash& hash)
|
|
||||||
{
|
|
||||||
RS_STACK_MUTEX(mDirStorageMtx) ;
|
|
||||||
mChanged = true ;
|
|
||||||
return mFileHierarchy->updateHash(index,hash);
|
|
||||||
}
|
|
||||||
|
|
||||||
void DirectoryStorage::getStatistics(SharedDirStats& stats)
|
void DirectoryStorage::getStatistics(SharedDirStats& stats)
|
||||||
{
|
{
|
||||||
RS_STACK_MUTEX(mDirStorageMtx) ;
|
RS_STACK_MUTEX(mDirStorageMtx) ;
|
||||||
@ -502,14 +489,18 @@ void LocalDirectoryStorage::updateTimeStamps()
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bool LocalDirectoryStorage::updateHash(const EntryIndex& index,const RsFileHash& hash)
|
bool LocalDirectoryStorage::updateHash(const EntryIndex& index, const RsFileHash& hash, bool update_internal_hierarchy)
|
||||||
{
|
{
|
||||||
{
|
RS_STACK_MUTEX(mDirStorageMtx) ;
|
||||||
RS_STACK_MUTEX(mDirStorageMtx) ;
|
|
||||||
|
|
||||||
mEncryptedHashes[makeEncryptedHash(hash)] = hash ;
|
mEncryptedHashes[makeEncryptedHash(hash)] = hash ;
|
||||||
}
|
mChanged = true ;
|
||||||
return mFileHierarchy->updateHash(index,hash);
|
|
||||||
|
#ifdef DEBUG_LOCAL_DIRECTORY_STORAGE
|
||||||
|
std::cerr << "Updating index of hash " << hash << " update_internal=" << update_internal_hierarchy << std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return (!update_internal_hierarchy)|| mFileHierarchy->updateHash(index,hash);
|
||||||
}
|
}
|
||||||
std::string LocalDirectoryStorage::locked_findRealRootFromVirtualFilename(const std::string& virtual_rootdir) const
|
std::string LocalDirectoryStorage::locked_findRealRootFromVirtualFilename(const std::string& virtual_rootdir) const
|
||||||
{
|
{
|
||||||
|
@ -136,13 +136,6 @@ class DirectoryStorage
|
|||||||
bool updateSubFilesList(const EntryIndex& indx, const std::map<std::string, FileTS> &subfiles, std::map<std::string, FileTS> &new_files) ;
|
bool updateSubFilesList(const EntryIndex& indx, const std::map<std::string, FileTS> &subfiles, std::map<std::string, FileTS> &new_files) ;
|
||||||
bool removeDirectory(const EntryIndex& indx) ;
|
bool removeDirectory(const EntryIndex& indx) ;
|
||||||
|
|
||||||
// Updates relevant information for the file at the given index.
|
|
||||||
|
|
||||||
bool updateFile(const EntryIndex& index,const RsFileHash& hash, const std::string& fname, uint64_t size, time_t modf_time) ;
|
|
||||||
|
|
||||||
// This is derived in LocalDirectoryStorage in order to also store H(H(F))
|
|
||||||
virtual bool updateHash(const EntryIndex& index,const RsFileHash& hash);
|
|
||||||
|
|
||||||
// Returns the hash of the directory at the given index and reverse. This hash is set as random the first time it is used (when updating directories). It will be
|
// Returns the hash of the directory at the given index and reverse. This hash is set as random the first time it is used (when updating directories). It will be
|
||||||
// used by the sync system to designate the directory without referring to index (index could be used to figure out the existance of hidden directories)
|
// used by the sync system to designate the directory without referring to index (index could be used to figure out the existance of hidden directories)
|
||||||
|
|
||||||
@ -231,7 +224,7 @@ public:
|
|||||||
void updateShareFlags(const SharedDirInfo& info) ;
|
void updateShareFlags(const SharedDirInfo& info) ;
|
||||||
bool convertSharedFilePath(const std::string& path_with_virtual_name,std::string& fullpath) ;
|
bool convertSharedFilePath(const std::string& path_with_virtual_name,std::string& fullpath) ;
|
||||||
|
|
||||||
virtual bool updateHash(const EntryIndex& index,const RsFileHash& hash);
|
virtual bool updateHash(const EntryIndex& index, const RsFileHash& hash, bool update_internal_hierarchy);
|
||||||
/*!
|
/*!
|
||||||
* \brief searchHash
|
* \brief searchHash
|
||||||
* Looks into local database of shared files for the given hash. Also looks for files such that the hash of the hash
|
* Looks into local database of shared files for the given hash. Also looks for files such that the hash of the hash
|
||||||
|
@ -73,11 +73,14 @@ void LocalDirectoryUpdater::data_tick()
|
|||||||
|
|
||||||
if(now > mDelayBetweenDirectoryUpdates + mLastSweepTime)
|
if(now > mDelayBetweenDirectoryUpdates + mLastSweepTime)
|
||||||
{
|
{
|
||||||
sweepSharedDirectories() ;
|
if(sweepSharedDirectories())
|
||||||
|
{
|
||||||
mNeedsFullRecheck = false ;
|
mNeedsFullRecheck = false ;
|
||||||
mLastSweepTime = now;
|
mLastSweepTime = now;
|
||||||
mSharedDirectories->notifyTSChanged() ;
|
mSharedDirectories->notifyTSChanged() ;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
std::cerr << "(WW) sweepSharedDirectories() failed. Will do it again in a short time." << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(now > DELAY_BETWEEN_LOCAL_DIRECTORIES_TS_UPDATE + mLastTSUpdateTime)
|
if(now > DELAY_BETWEEN_LOCAL_DIRECTORIES_TS_UPDATE + mLastTSUpdateTime)
|
||||||
@ -93,12 +96,12 @@ void LocalDirectoryUpdater::forceUpdate()
|
|||||||
mLastSweepTime = 0;
|
mLastSweepTime = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LocalDirectoryUpdater::sweepSharedDirectories()
|
bool LocalDirectoryUpdater::sweepSharedDirectories()
|
||||||
{
|
{
|
||||||
if(mHashSalt.isNull())
|
if(mHashSalt.isNull())
|
||||||
{
|
{
|
||||||
std::cerr << "(EE) no salt value in LocalDirectoryUpdater. Is that a bug?" << std::endl;
|
std::cerr << "(EE) no salt value in LocalDirectoryUpdater. Is that a bug?" << std::endl;
|
||||||
return ;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
RsServer::notify()->notifyListPreChange(NOTIFY_LIST_DIRLIST_LOCAL, 0);
|
RsServer::notify()->notifyListPreChange(NOTIFY_LIST_DIRLIST_LOCAL, 0);
|
||||||
@ -142,6 +145,7 @@ void LocalDirectoryUpdater::sweepSharedDirectories()
|
|||||||
}
|
}
|
||||||
|
|
||||||
RsServer::notify()->notifyListChange(NOTIFY_LIST_DIRLIST_LOCAL, 0);
|
RsServer::notify()->notifyListChange(NOTIFY_LIST_DIRLIST_LOCAL, 0);
|
||||||
|
return true ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LocalDirectoryUpdater::recursUpdateSharedDir(const std::string& cumulated_path, DirectoryStorage::EntryIndex indx,std::set<std::string>& existing_directories)
|
void LocalDirectoryUpdater::recursUpdateSharedDir(const std::string& cumulated_path, DirectoryStorage::EntryIndex indx,std::set<std::string>& existing_directories)
|
||||||
@ -221,8 +225,10 @@ void LocalDirectoryUpdater::recursUpdateSharedDir(const std::string& cumulated_p
|
|||||||
|
|
||||||
RsFileHash hash ;
|
RsFileHash hash ;
|
||||||
|
|
||||||
if(mHashCache->requestHash(cumulated_path + "/" + dit.name(),dit.size(),dit.modtime(),hash,this,*dit) && dit.hash() != hash)
|
// mSharedDirectories des two things: store H(F), and compute H(H(F)), which is used in FT. The later is always needed.
|
||||||
mSharedDirectories->updateHash(*dit,hash);
|
|
||||||
|
if(mHashCache->requestHash(cumulated_path + "/" + dit.name(),dit.size(),dit.modtime(),hash,this,*dit))
|
||||||
|
mSharedDirectories->updateHash(*dit,hash,hash != dit.hash());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifdef DEBUG_LOCAL_DIR_UPDATER
|
#ifdef DEBUG_LOCAL_DIR_UPDATER
|
||||||
@ -248,7 +254,7 @@ bool LocalDirectoryUpdater::inDirectoryCheck() const
|
|||||||
|
|
||||||
void LocalDirectoryUpdater::hash_callback(uint32_t client_param, const std::string &/*name*/, const RsFileHash &hash, uint64_t /*size*/)
|
void LocalDirectoryUpdater::hash_callback(uint32_t client_param, const std::string &/*name*/, const RsFileHash &hash, uint64_t /*size*/)
|
||||||
{
|
{
|
||||||
if(!mSharedDirectories->updateHash(DirectoryStorage::EntryIndex(client_param),hash))
|
if(!mSharedDirectories->updateHash(DirectoryStorage::EntryIndex(client_param),hash,true))
|
||||||
std::cerr << "(EE) Cannot update file. Something's wrong." << std::endl;
|
std::cerr << "(EE) Cannot update file. Something's wrong." << std::endl;
|
||||||
|
|
||||||
mSharedDirectories->notifyTSChanged() ;
|
mSharedDirectories->notifyTSChanged() ;
|
||||||
|
@ -60,7 +60,7 @@ protected:
|
|||||||
virtual bool hash_confirm(uint32_t client_param) ;
|
virtual bool hash_confirm(uint32_t client_param) ;
|
||||||
|
|
||||||
void recursUpdateSharedDir(const std::string& cumulated_path, DirectoryStorage::EntryIndex indx, std::set<std::string>& existing_directories);
|
void recursUpdateSharedDir(const std::string& cumulated_path, DirectoryStorage::EntryIndex indx, std::set<std::string>& existing_directories);
|
||||||
void sweepSharedDirectories();
|
bool sweepSharedDirectories();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
HashStorage *mHashCache ;
|
HashStorage *mHashCache ;
|
||||||
|
Loading…
Reference in New Issue
Block a user