mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-27 08:29:26 -05:00
Merge pull request #572 from csoler/v0.6-FileListsOptim
V0.6 file lists optim
This commit is contained in:
commit
fe965d2335
@ -141,7 +141,7 @@ void LocalDirectoryUpdater::recursUpdateSharedDir(const std::string& cumulated_p
|
||||
// make sure list of subfiles is the same
|
||||
// request all hashes to the hashcache
|
||||
|
||||
librs::util::FolderIterator dirIt(cumulated_path);
|
||||
librs::util::FolderIterator dirIt(cumulated_path,false,false); // disallow symbolic links and files from the future.
|
||||
|
||||
time_t dir_local_mod_time ;
|
||||
if(!mSharedDirectories->getDirectoryLocalModTime(indx,dir_local_mod_time))
|
||||
|
@ -145,7 +145,9 @@ void HashStorage::data_tick()
|
||||
|
||||
if(job.client->hash_confirm(job.client_param))
|
||||
{
|
||||
#ifdef HASHSTORAGE_DEBUG
|
||||
std::cerr << "Hashing file " << job.full_path << "..." ; std::cerr.flush();
|
||||
#endif
|
||||
|
||||
std::string tmpout;
|
||||
rs_sprintf(tmpout, "%lu/%lu (%s - %d%%) : %s", (unsigned long int)mHashCounter+1, (unsigned long int)mTotalFilesToHash, friendlyUnit(mTotalHashedSize).c_str(), int(mTotalHashedSize/double(mTotalSizeToHash)*100.0), job.full_path.c_str()) ;
|
||||
@ -156,7 +158,9 @@ void HashStorage::data_tick()
|
||||
{
|
||||
// store the result
|
||||
|
||||
#ifdef HASHSTORAGE_DEBUG
|
||||
std::cerr << "done."<< std::endl;
|
||||
#endif
|
||||
|
||||
RS_STACK_MUTEX(mHashMtx) ;
|
||||
HashStorageInfo& info(mFiles[job.full_path]);
|
||||
|
@ -138,7 +138,8 @@ void RsPluginManager::loadPlugins(const std::vector<std::string>& plugin_directo
|
||||
|
||||
for(uint32_t i=0;i<plugin_directories.size();++i)
|
||||
{
|
||||
librs::util::FolderIterator dirIt(plugin_directories[i]);
|
||||
librs::util::FolderIterator dirIt(plugin_directories[i],true);
|
||||
|
||||
if(!dirIt.isValid())
|
||||
{
|
||||
std::cerr << "Plugin directory : " << plugin_directories[i] << " does not exist." << std::endl ;
|
||||
|
@ -517,7 +517,8 @@ bool RsAccountsDetail::getAvailableAccounts(std::map<RsPeerId, AccountDetails> &
|
||||
*/
|
||||
|
||||
/* check for the dir existance */
|
||||
librs::util::FolderIterator dirIt(mBaseDirectory);
|
||||
librs::util::FolderIterator dirIt(mBaseDirectory,false);
|
||||
|
||||
if (!dirIt.isValid())
|
||||
{
|
||||
std::cerr << "Cannot Open Base Dir - No Available Accounts" << std::endl;
|
||||
|
@ -16,8 +16,8 @@
|
||||
namespace librs { namespace util {
|
||||
|
||||
|
||||
FolderIterator::FolderIterator(const std::string& folderName)
|
||||
: mFolderName(folderName)
|
||||
FolderIterator::FolderIterator(const std::string& folderName, bool allow_symlinks, bool allow_files_from_the_future)
|
||||
: mFolderName(folderName),mAllowSymLinks(allow_symlinks),mAllowFilesFromTheFuture(allow_files_from_the_future)
|
||||
{
|
||||
is_open = false ;
|
||||
validity = false ;
|
||||
@ -112,6 +112,19 @@ bool FolderIterator::updateFileInfo(bool& should_skip)
|
||||
|
||||
mFullPath = mFolderName + "/" + mFileName ;
|
||||
|
||||
if( ent->d_type == DT_LNK && !mAllowSymLinks)
|
||||
{
|
||||
std::cerr << "(II) Skipping symbolic link " << mFullPath << std::endl;
|
||||
should_skip = true ;
|
||||
return true ;
|
||||
}
|
||||
else if( ent->d_type != DT_DIR && ent->d_type != DT_REG)
|
||||
{
|
||||
std::cerr << "(II) Skipping file of unknown type " << ent->d_type << ": " << mFullPath << std::endl;
|
||||
should_skip = true ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
struct stat64 buf ;
|
||||
|
||||
#ifdef DEBUG_FOLDER_ITERATOR
|
||||
@ -128,6 +141,13 @@ bool FolderIterator::updateFileInfo(bool& should_skip)
|
||||
{
|
||||
mFileModTime = buf.st_mtime ;
|
||||
|
||||
if(buf.st_mtime > time(NULL) && !mAllowFilesFromTheFuture)
|
||||
{
|
||||
std::cerr << "(II) skipping file with modification time in the future: " << mFullPath << std::endl;
|
||||
should_skip = true ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
if (S_ISDIR(buf.st_mode))
|
||||
{
|
||||
#ifdef DEBUG_FOLDER_ITERATOR
|
||||
|
@ -22,7 +22,7 @@ namespace librs { namespace util {
|
||||
class FolderIterator
|
||||
{
|
||||
public:
|
||||
FolderIterator(const std::string& folderName);
|
||||
FolderIterator(const std::string& folderName,bool allow_symlinks,bool allow_files_from_the_future = true);
|
||||
~FolderIterator();
|
||||
|
||||
enum { TYPE_UNKNOWN = 0x00,
|
||||
@ -68,6 +68,8 @@ private:
|
||||
std::string mFileName ;
|
||||
std::string mFullPath ;
|
||||
std::string mFolderName ;
|
||||
bool mAllowSymLinks;
|
||||
bool mAllowFilesFromTheFuture;
|
||||
};
|
||||
|
||||
|
||||
|
@ -438,7 +438,7 @@ bool RsDirUtil::checkCreateDirectory(const std::string& dir)
|
||||
|
||||
bool RsDirUtil::cleanupDirectory(const std::string& cleandir, const std::set<std::string> &keepFiles)
|
||||
{
|
||||
for(librs::util::FolderIterator it(cleandir);it.isValid();it.next())
|
||||
for(librs::util::FolderIterator it(cleandir,false);it.isValid();it.next())
|
||||
if(it.file_type() == librs::util::FolderIterator::TYPE_FILE && (keepFiles.end() == std::find(keepFiles.begin(), keepFiles.end(), it.file_name())))
|
||||
remove( (cleandir + "/" + it.file_name()).c_str() ) ;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user