moved file ignore test to a more appropriate place

This commit is contained in:
csoler 2017-09-11 19:02:07 +02:00
parent eff5c5d6ee
commit 0ca0b72a5a
2 changed files with 29 additions and 23 deletions

View File

@ -199,25 +199,26 @@ void LocalDirectoryUpdater::recursUpdateSharedDir(const std::string& cumulated_p
std::set<std::string> subdirs ; std::set<std::string> subdirs ;
for(;dirIt.isValid();dirIt.next()) for(;dirIt.isValid();dirIt.next())
{ if(filterFile(dirIt.file_name()))
switch(dirIt.file_type()) {
{ switch(dirIt.file_type())
case librs::util::FolderIterator::TYPE_FILE: subfiles[dirIt.file_name()].modtime = dirIt.file_modtime() ; {
subfiles[dirIt.file_name()].size = dirIt.file_size(); case librs::util::FolderIterator::TYPE_FILE: subfiles[dirIt.file_name()].modtime = dirIt.file_modtime() ;
subfiles[dirIt.file_name()].size = dirIt.file_size();
#ifdef DEBUG_LOCAL_DIR_UPDATER #ifdef DEBUG_LOCAL_DIR_UPDATER
std::cerr << " adding sub-file \"" << dirIt.file_name() << "\"" << std::endl; std::cerr << " adding sub-file \"" << dirIt.file_name() << "\"" << std::endl;
#endif #endif
break; break;
case librs::util::FolderIterator::TYPE_DIR: subdirs.insert(dirIt.file_name()); case librs::util::FolderIterator::TYPE_DIR: subdirs.insert(dirIt.file_name());
#ifdef DEBUG_LOCAL_DIR_UPDATER #ifdef DEBUG_LOCAL_DIR_UPDATER
std::cerr << " adding sub-dir \"" << dirIt.file_name() << "\"" << std::endl; std::cerr << " adding sub-dir \"" << dirIt.file_name() << "\"" << std::endl;
#endif #endif
break; break;
default: default:
std::cerr << "(EE) Dir entry of unknown type with path \"" << cumulated_path << "/" << dirIt.file_name() << "\"" << std::endl; std::cerr << "(EE) Dir entry of unknown type with path \"" << cumulated_path << "/" << dirIt.file_name() << "\"" << std::endl;
} }
} }
// update folder modificatoin time, which is the only way to detect e.g. removed or renamed files. // update folder modificatoin time, which is the only way to detect e.g. removed or renamed files.
mSharedDirectories->setDirectoryLocalModTime(indx,dirIt.dir_modtime()) ; mSharedDirectories->setDirectoryLocalModTime(indx,dirIt.dir_modtime()) ;
@ -232,17 +233,16 @@ void LocalDirectoryUpdater::recursUpdateSharedDir(const std::string& cumulated_p
// now go through list of subfiles and request the hash to hashcache // now go through list of subfiles and request the hash to hashcache
for(DirectoryStorage::FileIterator dit(mSharedDirectories,indx);dit;++dit) for(DirectoryStorage::FileIterator dit(mSharedDirectories,indx);dit;++dit)
if(filterFile(dit.name())) {
{ // ask about the hash. If not present, ask HashCache. If not present, or different, the callback will update it.
// ask about the hash. If not present, ask HashCache. If not present, or different, the callback will update it.
RsFileHash hash ; RsFileHash hash ;
// mSharedDirectories does two things: store H(F), and compute H(H(F)), which is used in FT. The later is always needed. // mSharedDirectories does 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)) if(mHashCache->requestHash(cumulated_path + "/" + dit.name(),dit.size(),dit.modtime(),hash,this,*dit))
mSharedDirectories->updateHash(*dit,hash,hash != dit.hash()); mSharedDirectories->updateHash(*dit,hash,hash != dit.hash());
} }
} }
#ifdef DEBUG_LOCAL_DIR_UPDATER #ifdef DEBUG_LOCAL_DIR_UPDATER
else else
@ -265,12 +265,18 @@ bool LocalDirectoryUpdater::filterFile(const std::string& fname) const
if(mIgnoreFlags & RS_FILE_SHARE_FLAGS_IGNORE_SUFFIXES) if(mIgnoreFlags & RS_FILE_SHARE_FLAGS_IGNORE_SUFFIXES)
for(auto it(mIgnoredSuffixes.begin());it!=mIgnoredSuffixes.end();++it) for(auto it(mIgnoredSuffixes.begin());it!=mIgnoredSuffixes.end();++it)
if(fname.size() >= (*it).size() && fname.substr( fname.size() - (*it).size()) == *it) if(fname.size() >= (*it).size() && fname.substr( fname.size() - (*it).size()) == *it)
{
std::cerr << "(II) ignoring file " << fname << ", because it matches suffix \"" << *it << "\"" << std::endl;
return false ; return false ;
}
if(mIgnoreFlags & RS_FILE_SHARE_FLAGS_IGNORE_PREFIXES) if(mIgnoreFlags & RS_FILE_SHARE_FLAGS_IGNORE_PREFIXES)
for(auto it(mIgnoredPrefixes.begin());it!=mIgnoredPrefixes.end();++it) for(auto it(mIgnoredPrefixes.begin());it!=mIgnoredPrefixes.end();++it)
if(fname.size() >= (*it).size() && fname.substr( 0,(*it).size()) == *it) if(fname.size() >= (*it).size() && fname.substr( 0,(*it).size()) == *it)
{
std::cerr << "(II) ignoring file " << fname << ", because it matches prefix \"" << *it << "\"" << std::endl;
return false ; return false ;
}
return true ; return true ;
} }

View File

@ -157,7 +157,7 @@ void HashStorage::data_tick()
paused = mHashingProcessPaused ; paused = mHashingProcessPaused ;
} }
if(paused) if(paused) // we need to wait off mutex!!
{ {
usleep(MAX_INACTIVITY_SLEEP_TIME) ; usleep(MAX_INACTIVITY_SLEEP_TIME) ;
std::cerr << "Hashing process currently paused." << std::endl; std::cerr << "Hashing process currently paused." << std::endl;