Merge pull request #601 from csoler/v0.6-FileListsOptim

removed unused updateHash() functions in directory_storage. Fixed a b…
This commit is contained in:
csoler 2016-12-15 09:31:20 +01:00 committed by GitHub
commit 31b1583c36
4 changed files with 28 additions and 38 deletions

View File

@ -160,19 +160,6 @@ void DirectoryStorage::locked_check()
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)
{
RS_STACK_MUTEX(mDirStorageMtx) ;
@ -502,14 +489,18 @@ void LocalDirectoryStorage::updateTimeStamps()
#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 ;
}
return mFileHierarchy->updateHash(index,hash);
mEncryptedHashes[makeEncryptedHash(hash)] = hash ;
mChanged = true ;
#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
{

View File

@ -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 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
// 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) ;
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
* Looks into local database of shared files for the given hash. Also looks for files such that the hash of the hash

View File

@ -73,11 +73,14 @@ void LocalDirectoryUpdater::data_tick()
if(now > mDelayBetweenDirectoryUpdates + mLastSweepTime)
{
sweepSharedDirectories() ;
mNeedsFullRecheck = false ;
mLastSweepTime = now;
mSharedDirectories->notifyTSChanged() ;
if(sweepSharedDirectories())
{
mNeedsFullRecheck = false ;
mLastSweepTime = now;
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)
@ -93,12 +96,12 @@ void LocalDirectoryUpdater::forceUpdate()
mLastSweepTime = 0;
}
void LocalDirectoryUpdater::sweepSharedDirectories()
bool LocalDirectoryUpdater::sweepSharedDirectories()
{
if(mHashSalt.isNull())
{
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);
@ -142,6 +145,7 @@ void LocalDirectoryUpdater::sweepSharedDirectories()
}
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)
@ -221,8 +225,10 @@ void LocalDirectoryUpdater::recursUpdateSharedDir(const std::string& cumulated_p
RsFileHash hash ;
if(mHashCache->requestHash(cumulated_path + "/" + dit.name(),dit.size(),dit.modtime(),hash,this,*dit) && dit.hash() != hash)
mSharedDirectories->updateHash(*dit,hash);
// mSharedDirectories des two things: store H(F), and compute H(H(F)), which is used in FT. The later is always needed.
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
@ -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*/)
{
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;
mSharedDirectories->notifyTSChanged() ;

View File

@ -60,7 +60,7 @@ protected:
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 sweepSharedDirectories();
bool sweepSharedDirectories();
private:
HashStorage *mHashCache ;