mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-27 08:29:26 -05:00
commit
b969f313b0
@ -40,9 +40,10 @@ LocalDirectoryUpdater::LocalDirectoryUpdater(HashStorage *hc,LocalDirectoryStora
|
|||||||
, mLastSweepTime(0), mLastTSUpdateTime(0)
|
, mLastSweepTime(0), mLastTSUpdateTime(0)
|
||||||
, mDelayBetweenDirectoryUpdates(DELAY_BETWEEN_DIRECTORY_UPDATES)
|
, mDelayBetweenDirectoryUpdates(DELAY_BETWEEN_DIRECTORY_UPDATES)
|
||||||
, mIsEnabled(false), mFollowSymLinks(FOLLOW_SYMLINKS_DEFAULT)
|
, mIsEnabled(false), mFollowSymLinks(FOLLOW_SYMLINKS_DEFAULT)
|
||||||
|
, mIgnoreDuplicates(true)
|
||||||
/* Can be left to false, but setting it to true will force to re-hash any file that has been left unhashed in the last session.*/
|
/* Can be left to false, but setting it to true will force to re-hash any file that has been left unhashed in the last session.*/
|
||||||
, mNeedsFullRecheck(true)
|
, mNeedsFullRecheck(true)
|
||||||
, mIsChecking(false), mForceUpdate(false), mIgnoreFlags (0)
|
, mIsChecking(false), mForceUpdate(false), mIgnoreFlags (0), mMaxShareDepth(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -146,8 +147,9 @@ bool LocalDirectoryUpdater::sweepSharedDirectories()
|
|||||||
#ifdef DEBUG_LOCAL_DIR_UPDATER
|
#ifdef DEBUG_LOCAL_DIR_UPDATER
|
||||||
std::cerr << "[directory storage] recursing into " << stored_dir_it.name() << std::endl;
|
std::cerr << "[directory storage] recursing into " << stored_dir_it.name() << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
existing_dirs.insert(RsDirUtil::removeSymLinks(stored_dir_it.name()));
|
||||||
|
|
||||||
recursUpdateSharedDir(stored_dir_it.name(), *stored_dir_it,existing_dirs) ; // here we need to use the list that was stored, instead of the shared dir list, because the two
|
recursUpdateSharedDir(stored_dir_it.name(), *stored_dir_it,existing_dirs,1) ; // here we need to use the list that was stored, instead of the shared dir list, because the two
|
||||||
// are not necessarily in the same order.
|
// are not necessarily in the same order.
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -157,23 +159,12 @@ bool LocalDirectoryUpdater::sweepSharedDirectories()
|
|||||||
return true ;
|
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,uint32_t current_depth)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_LOCAL_DIR_UPDATER
|
#ifdef DEBUG_LOCAL_DIR_UPDATER
|
||||||
std::cerr << "[directory storage] parsing directory " << cumulated_path << ", index=" << indx << std::endl;
|
std::cerr << "[directory storage] parsing directory " << cumulated_path << ", index=" << indx << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if(mFollowSymLinks)
|
|
||||||
{
|
|
||||||
std::string real_path = RsDirUtil::removeSymLinks(cumulated_path) ;
|
|
||||||
if(existing_directories.end() != existing_directories.find(real_path))
|
|
||||||
{
|
|
||||||
std::cerr << "(WW) Directory " << cumulated_path << " has real path " << real_path << " which already belongs to another shared directory. Ignoring" << std::endl;
|
|
||||||
return ;
|
|
||||||
}
|
|
||||||
existing_directories.insert(real_path) ;
|
|
||||||
}
|
|
||||||
|
|
||||||
// make sure list of subdirs is the same
|
// make sure list of subdirs is the same
|
||||||
// make sure list of subfiles is the same
|
// make sure list of subfiles is the same
|
||||||
// request all hashes to the hashcache
|
// request all hashes to the hashcache
|
||||||
@ -207,10 +198,33 @@ void LocalDirectoryUpdater::recursUpdateSharedDir(const std::string& cumulated_p
|
|||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case librs::util::FolderIterator::TYPE_DIR: subdirs.insert(dirIt.file_name());
|
case librs::util::FolderIterator::TYPE_DIR:
|
||||||
|
{
|
||||||
|
bool dir_is_accepted = true ;
|
||||||
|
|
||||||
|
if( (mMaxShareDepth > 0u && current_depth > mMaxShareDepth) || (mMaxShareDepth==0 && current_depth >= 64)) // 64 is here as a safe limit, to make loops impossible.
|
||||||
|
dir_is_accepted = false ;
|
||||||
|
|
||||||
|
if(dir_is_accepted && mFollowSymLinks && mIgnoreDuplicates)
|
||||||
|
{
|
||||||
|
std::string real_path = RsDirUtil::removeSymLinks(cumulated_path + "/" + dirIt.file_name()) ;
|
||||||
|
|
||||||
|
if(existing_directories.end() != existing_directories.find(real_path))
|
||||||
|
{
|
||||||
|
std::cerr << "(WW) Directory " << cumulated_path << " has real path " << real_path << " which already belongs to another shared directory. Ignoring" << std::endl;
|
||||||
|
dir_is_accepted = false ;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
existing_directories.insert(real_path) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(dir_is_accepted)
|
||||||
|
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;
|
||||||
@ -248,13 +262,13 @@ void LocalDirectoryUpdater::recursUpdateSharedDir(const std::string& cumulated_p
|
|||||||
|
|
||||||
// go through the list of sub-dirs and recursively update
|
// go through the list of sub-dirs and recursively update
|
||||||
|
|
||||||
for(DirectoryStorage::DirIterator stored_dir_it(mSharedDirectories,indx) ; stored_dir_it; ++stored_dir_it)
|
for(DirectoryStorage::DirIterator stored_dir_it(mSharedDirectories,indx) ; stored_dir_it; ++stored_dir_it)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_LOCAL_DIR_UPDATER
|
#ifdef DEBUG_LOCAL_DIR_UPDATER
|
||||||
std::cerr << " recursing into " << stored_dir_it.name() << std::endl;
|
std::cerr << " recursing into " << stored_dir_it.name() << std::endl;
|
||||||
#endif
|
#endif
|
||||||
recursUpdateSharedDir(cumulated_path + "/" + stored_dir_it.name(), *stored_dir_it,existing_directories) ;
|
recursUpdateSharedDir(cumulated_path + "/" + stored_dir_it.name(), *stored_dir_it,existing_directories,current_depth+1) ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LocalDirectoryUpdater::filterFile(const std::string& fname) const
|
bool LocalDirectoryUpdater::filterFile(const std::string& fname) const
|
||||||
@ -344,4 +358,28 @@ bool LocalDirectoryUpdater::getIgnoreLists(std::list<std::string>& ignored_prefi
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int LocalDirectoryUpdater::maxShareDepth() const
|
||||||
|
{
|
||||||
|
return mMaxShareDepth ;
|
||||||
|
}
|
||||||
|
|
||||||
|
void LocalDirectoryUpdater::setMaxShareDepth(uint32_t d)
|
||||||
|
{
|
||||||
|
if(d != mMaxShareDepth)
|
||||||
|
mNeedsFullRecheck = true ;
|
||||||
|
|
||||||
|
mMaxShareDepth = d ;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool LocalDirectoryUpdater::ignoreDuplicates() const
|
||||||
|
{
|
||||||
|
return mIgnoreDuplicates;
|
||||||
|
}
|
||||||
|
|
||||||
|
void LocalDirectoryUpdater::setIgnoreDuplicates(bool b)
|
||||||
|
{
|
||||||
|
if(b != mIgnoreDuplicates)
|
||||||
|
mNeedsFullRecheck = true ;
|
||||||
|
|
||||||
|
mIgnoreDuplicates = b ;
|
||||||
|
}
|
||||||
|
@ -58,13 +58,19 @@ public:
|
|||||||
void setIgnoreLists(const std::list<std::string>& ignored_prefixes,const std::list<std::string>& ignored_suffixes,uint32_t ignore_flags) ;
|
void setIgnoreLists(const std::list<std::string>& ignored_prefixes,const std::list<std::string>& ignored_suffixes,uint32_t ignore_flags) ;
|
||||||
bool getIgnoreLists(std::list<std::string>& ignored_prefixes,std::list<std::string>& ignored_suffixes,uint32_t& ignore_flags) const ;
|
bool getIgnoreLists(std::list<std::string>& ignored_prefixes,std::list<std::string>& ignored_suffixes,uint32_t& ignore_flags) const ;
|
||||||
|
|
||||||
|
void setMaxShareDepth(uint32_t i) ;
|
||||||
|
int maxShareDepth() const;
|
||||||
|
|
||||||
|
void setIgnoreDuplicates(bool b) ;
|
||||||
|
bool ignoreDuplicates() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void data_tick() ;
|
virtual void data_tick() ;
|
||||||
|
|
||||||
virtual void hash_callback(uint32_t client_param, const std::string& name, const RsFileHash& hash, uint64_t size);
|
virtual void hash_callback(uint32_t client_param, const std::string& name, const RsFileHash& hash, uint64_t size);
|
||||||
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, uint32_t current_depth);
|
||||||
bool sweepSharedDirectories();
|
bool sweepSharedDirectories();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -81,11 +87,14 @@ private:
|
|||||||
uint32_t mDelayBetweenDirectoryUpdates;
|
uint32_t mDelayBetweenDirectoryUpdates;
|
||||||
bool mIsEnabled ;
|
bool mIsEnabled ;
|
||||||
bool mFollowSymLinks;
|
bool mFollowSymLinks;
|
||||||
|
bool mIgnoreDuplicates;
|
||||||
bool mNeedsFullRecheck ;
|
bool mNeedsFullRecheck ;
|
||||||
bool mIsChecking ;
|
bool mIsChecking ;
|
||||||
bool mForceUpdate ;
|
bool mForceUpdate ;
|
||||||
|
|
||||||
uint32_t mIgnoreFlags ;
|
uint32_t mIgnoreFlags ;
|
||||||
|
uint32_t mMaxShareDepth ;
|
||||||
|
|
||||||
std::list<std::string> mIgnoredPrefixes ;
|
std::list<std::string> mIgnoredPrefixes ;
|
||||||
std::list<std::string> mIgnoredSuffixes ;
|
std::list<std::string> mIgnoredSuffixes ;
|
||||||
};
|
};
|
||||||
|
@ -38,10 +38,12 @@ static const std::string HASH_CACHE_DURATION_SS = "HASH_CACHE_DURATION" ; // ke
|
|||||||
static const std::string WATCH_FILE_DURATION_SS = "WATCH_FILES_DELAY" ; // key to store delay before re-checking for new files
|
static const std::string WATCH_FILE_DURATION_SS = "WATCH_FILES_DELAY" ; // key to store delay before re-checking for new files
|
||||||
static const std::string WATCH_FILE_ENABLED_SS = "WATCH_FILES_ENABLED"; // key to store ON/OFF flags for file whatch
|
static const std::string WATCH_FILE_ENABLED_SS = "WATCH_FILES_ENABLED"; // key to store ON/OFF flags for file whatch
|
||||||
static const std::string FOLLOW_SYMLINKS_SS = "FOLLOW_SYMLINKS"; // dereference symbolic links, or just ignore them.
|
static const std::string FOLLOW_SYMLINKS_SS = "FOLLOW_SYMLINKS"; // dereference symbolic links, or just ignore them.
|
||||||
|
static const std::string IGNORE_DUPLICATES = "IGNORE_DUPLICATES"; // do not index files that are referenced multiple times because of links
|
||||||
static const std::string WATCH_HASH_SALT_SS = "WATCH_HASH_SALT"; // Salt that is used to hash directory names
|
static const std::string WATCH_HASH_SALT_SS = "WATCH_HASH_SALT"; // Salt that is used to hash directory names
|
||||||
static const std::string IGNORED_PREFIXES_SS = "IGNORED_PREFIXES"; // ignore file prefixes
|
static const std::string IGNORED_PREFIXES_SS = "IGNORED_PREFIXES"; // ignore file prefixes
|
||||||
static const std::string IGNORED_SUFFIXES_SS = "IGNORED_SUFFIXES"; // ignore file suffixes
|
static const std::string IGNORED_SUFFIXES_SS = "IGNORED_SUFFIXES"; // ignore file suffixes
|
||||||
static const std::string IGNORE_LIST_FLAGS_SS = "IGNORED_FLAGS"; // ignore file flags
|
static const std::string IGNORE_LIST_FLAGS_SS = "IGNORED_FLAGS"; // ignore file flags
|
||||||
|
static const std::string MAX_SHARE_DEPTH = "MAX_SHARE_DEPTH"; // maximum depth of shared directories
|
||||||
|
|
||||||
static const std::string FILE_SHARING_DIR_NAME = "file_sharing" ; // hard-coded directory name to store friend file lists, hash cache, etc.
|
static const std::string FILE_SHARING_DIR_NAME = "file_sharing" ; // hard-coded directory name to store friend file lists, hash cache, etc.
|
||||||
static const std::string HASH_CACHE_FILE_NAME = "hash_cache.bin" ; // hard-coded directory name to store encrypted hash cache.
|
static const std::string HASH_CACHE_FILE_NAME = "hash_cache.bin" ; // hard-coded directory name to store encrypted hash cache.
|
||||||
|
@ -223,8 +223,10 @@ bool HashStorage::requestHash(const std::string& full_path,uint64_t size,time_t
|
|||||||
#endif
|
#endif
|
||||||
RS_STACK_MUTEX(mHashMtx) ;
|
RS_STACK_MUTEX(mHashMtx) ;
|
||||||
|
|
||||||
|
std::string real_path = RsDirUtil::removeSymLinks(full_path) ;
|
||||||
|
|
||||||
time_t now = time(NULL) ;
|
time_t now = time(NULL) ;
|
||||||
std::map<std::string,HashStorageInfo>::iterator it = mFiles.find(full_path) ;
|
std::map<std::string,HashStorageInfo>::iterator it = mFiles.find(real_path) ;
|
||||||
|
|
||||||
// On windows we compare the time up to +/- 3600 seconds. This avoids re-hashing files in case of daylight saving change.
|
// On windows we compare the time up to +/- 3600 seconds. This avoids re-hashing files in case of daylight saving change.
|
||||||
//
|
//
|
||||||
@ -261,7 +263,7 @@ bool HashStorage::requestHash(const std::string& full_path,uint64_t size,time_t
|
|||||||
|
|
||||||
// we need to schedule a re-hashing
|
// we need to schedule a re-hashing
|
||||||
|
|
||||||
if(mFilesToHash.find(full_path) != mFilesToHash.end())
|
if(mFilesToHash.find(real_path) != mFilesToHash.end())
|
||||||
return false ;
|
return false ;
|
||||||
|
|
||||||
FileHashJob job ;
|
FileHashJob job ;
|
||||||
@ -272,7 +274,10 @@ bool HashStorage::requestHash(const std::string& full_path,uint64_t size,time_t
|
|||||||
job.full_path = full_path ;
|
job.full_path = full_path ;
|
||||||
job.ts = mod_time ;
|
job.ts = mod_time ;
|
||||||
|
|
||||||
mFilesToHash[full_path] = job;
|
// We store the files indexed by their real path, so that we allow to not re-hash files that are pointed multiple times through the directory links
|
||||||
|
// The client will be notified with the full path instead of the real path.
|
||||||
|
|
||||||
|
mFilesToHash[real_path] = job;
|
||||||
|
|
||||||
mTotalSizeToHash += size ;
|
mTotalSizeToHash += size ;
|
||||||
++mTotalFilesToHash;
|
++mTotalFilesToHash;
|
||||||
|
@ -332,6 +332,17 @@ cleanup = true;
|
|||||||
kv.key = WATCH_FILE_DURATION_SS;
|
kv.key = WATCH_FILE_DURATION_SS;
|
||||||
kv.value = s ;
|
kv.value = s ;
|
||||||
|
|
||||||
|
rskv->tlvkvs.pairs.push_back(kv);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
std::string s ;
|
||||||
|
rs_sprintf(s, "%d", maxShareDepth()) ;
|
||||||
|
|
||||||
|
RsTlvKeyValue kv;
|
||||||
|
|
||||||
|
kv.key = MAX_SHARE_DEPTH;
|
||||||
|
kv.value = s ;
|
||||||
|
|
||||||
rskv->tlvkvs.pairs.push_back(kv);
|
rskv->tlvkvs.pairs.push_back(kv);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
@ -342,6 +353,14 @@ cleanup = true;
|
|||||||
|
|
||||||
rskv->tlvkvs.pairs.push_back(kv);
|
rskv->tlvkvs.pairs.push_back(kv);
|
||||||
}
|
}
|
||||||
|
{
|
||||||
|
RsTlvKeyValue kv;
|
||||||
|
|
||||||
|
kv.key = IGNORE_DUPLICATES;
|
||||||
|
kv.value = ignoreDuplicates()?"YES":"NO" ;
|
||||||
|
|
||||||
|
rskv->tlvkvs.pairs.push_back(kv);
|
||||||
|
}
|
||||||
{
|
{
|
||||||
RsTlvKeyValue kv;
|
RsTlvKeyValue kv;
|
||||||
|
|
||||||
@ -400,6 +419,7 @@ bool p3FileDatabase::loadList(std::list<RsItem *>& load)
|
|||||||
std::list<SharedDirInfo> dirList;
|
std::list<SharedDirInfo> dirList;
|
||||||
std::list<std::string> ignored_prefixes,ignored_suffixes ;
|
std::list<std::string> ignored_prefixes,ignored_suffixes ;
|
||||||
uint32_t ignore_flags = RS_FILE_SHARE_FLAGS_IGNORE_PREFIXES | RS_FILE_SHARE_FLAGS_IGNORE_SUFFIXES ;
|
uint32_t ignore_flags = RS_FILE_SHARE_FLAGS_IGNORE_PREFIXES | RS_FILE_SHARE_FLAGS_IGNORE_SUFFIXES ;
|
||||||
|
uint32_t max_share_depth = 0;
|
||||||
|
|
||||||
// OS-dependent default ignore lists
|
// OS-dependent default ignore lists
|
||||||
#ifdef WINDOWS_SYS
|
#ifdef WINDOWS_SYS
|
||||||
@ -433,10 +453,14 @@ bool p3FileDatabase::loadList(std::list<RsItem *>& load)
|
|||||||
if(sscanf(kit->value.c_str(),"%d",&t) == 1)
|
if(sscanf(kit->value.c_str(),"%d",&t) == 1)
|
||||||
setWatchPeriod(t);
|
setWatchPeriod(t);
|
||||||
}
|
}
|
||||||
else if(kit->key == FOLLOW_SYMLINKS_SS)
|
else if(kit->key == FOLLOW_SYMLINKS_SS)
|
||||||
{
|
{
|
||||||
setFollowSymLinks(kit->value == "YES") ;
|
setFollowSymLinks(kit->value == "YES") ;
|
||||||
}
|
}
|
||||||
|
else if(kit->key == IGNORE_DUPLICATES)
|
||||||
|
{
|
||||||
|
setIgnoreDuplicates(kit->value == "YES") ;
|
||||||
|
}
|
||||||
else if(kit->key == WATCH_FILE_ENABLED_SS)
|
else if(kit->key == WATCH_FILE_ENABLED_SS)
|
||||||
{
|
{
|
||||||
setWatchEnabled(kit->value == "YES") ;
|
setWatchEnabled(kit->value == "YES") ;
|
||||||
@ -480,6 +504,12 @@ bool p3FileDatabase::loadList(std::list<RsItem *>& load)
|
|||||||
if(sscanf(kit->value.c_str(),"%d",&t) == 1)
|
if(sscanf(kit->value.c_str(),"%d",&t) == 1)
|
||||||
ignore_flags = (uint32_t)t ;
|
ignore_flags = (uint32_t)t ;
|
||||||
}
|
}
|
||||||
|
else if(kit->key == MAX_SHARE_DEPTH)
|
||||||
|
{
|
||||||
|
int t=0 ;
|
||||||
|
if(sscanf(kit->value.c_str(),"%d",&t) == 1)
|
||||||
|
max_share_depth = (uint32_t)t ;
|
||||||
|
}
|
||||||
|
|
||||||
delete *it ;
|
delete *it ;
|
||||||
continue ;
|
continue ;
|
||||||
@ -509,6 +539,7 @@ bool p3FileDatabase::loadList(std::list<RsItem *>& load)
|
|||||||
/* set directories */
|
/* set directories */
|
||||||
mLocalSharedDirs->setSharedDirectoryList(dirList);
|
mLocalSharedDirs->setSharedDirectoryList(dirList);
|
||||||
mLocalDirWatcher->setIgnoreLists(ignored_prefixes,ignored_suffixes,ignore_flags) ;
|
mLocalDirWatcher->setIgnoreLists(ignored_prefixes,ignored_suffixes,ignore_flags) ;
|
||||||
|
mLocalDirWatcher->setMaxShareDepth(max_share_depth);
|
||||||
|
|
||||||
load.clear() ;
|
load.clear() ;
|
||||||
|
|
||||||
@ -1070,6 +1101,28 @@ bool p3FileDatabase::followSymLinks() const
|
|||||||
RS_STACK_MUTEX(mFLSMtx) ;
|
RS_STACK_MUTEX(mFLSMtx) ;
|
||||||
return mLocalDirWatcher->followSymLinks() ;
|
return mLocalDirWatcher->followSymLinks() ;
|
||||||
}
|
}
|
||||||
|
void p3FileDatabase::setIgnoreDuplicates(bool i)
|
||||||
|
{
|
||||||
|
RS_STACK_MUTEX(mFLSMtx) ;
|
||||||
|
mLocalDirWatcher->setIgnoreDuplicates(i) ;
|
||||||
|
IndicateConfigChanged();
|
||||||
|
}
|
||||||
|
bool p3FileDatabase::ignoreDuplicates() const
|
||||||
|
{
|
||||||
|
RS_STACK_MUTEX(mFLSMtx) ;
|
||||||
|
return mLocalDirWatcher->ignoreDuplicates() ;
|
||||||
|
}
|
||||||
|
void p3FileDatabase::setMaxShareDepth(int i)
|
||||||
|
{
|
||||||
|
RS_STACK_MUTEX(mFLSMtx) ;
|
||||||
|
mLocalDirWatcher->setMaxShareDepth(i) ;
|
||||||
|
IndicateConfigChanged();
|
||||||
|
}
|
||||||
|
int p3FileDatabase::maxShareDepth() const
|
||||||
|
{
|
||||||
|
RS_STACK_MUTEX(mFLSMtx) ;
|
||||||
|
return mLocalDirWatcher->maxShareDepth() ;
|
||||||
|
}
|
||||||
void p3FileDatabase::setWatchEnabled(bool b)
|
void p3FileDatabase::setWatchEnabled(bool b)
|
||||||
{
|
{
|
||||||
RS_STACK_MUTEX(mFLSMtx) ;
|
RS_STACK_MUTEX(mFLSMtx) ;
|
||||||
|
@ -130,6 +130,12 @@ class p3FileDatabase: public p3Service, public p3Config, public ftSearch //, pub
|
|||||||
void setIgnoreLists(const std::list<std::string>& ignored_prefixes,const std::list<std::string>& ignored_suffixes, uint32_t ignore_flags) ;
|
void setIgnoreLists(const std::list<std::string>& ignored_prefixes,const std::list<std::string>& ignored_suffixes, uint32_t ignore_flags) ;
|
||||||
bool getIgnoreLists(std::list<std::string>& ignored_prefixes,std::list<std::string>& ignored_suffixes, uint32_t& ignore_flags) ;
|
bool getIgnoreLists(std::list<std::string>& ignored_prefixes,std::list<std::string>& ignored_suffixes, uint32_t& ignore_flags) ;
|
||||||
|
|
||||||
|
void setIgnoreDuplicates(bool i) ;
|
||||||
|
bool ignoreDuplicates() const ;
|
||||||
|
|
||||||
|
void setMaxShareDepth(int i) ;
|
||||||
|
int maxShareDepth() const ;
|
||||||
|
|
||||||
// computes/gathers statistics about shared directories
|
// computes/gathers statistics about shared directories
|
||||||
|
|
||||||
int getSharedDirStatistics(const RsPeerId& pid,SharedDirStats& stats);
|
int getSharedDirStatistics(const RsPeerId& pid,SharedDirStats& stats);
|
||||||
|
@ -839,10 +839,14 @@ void ftServer::setIgnoreLists(const std::list<std::string>& ignored_prefixes, co
|
|||||||
bool ftServer::watchEnabled() { return mFileDatabase->watchEnabled() ; }
|
bool ftServer::watchEnabled() { return mFileDatabase->watchEnabled() ; }
|
||||||
int ftServer::watchPeriod() const { return mFileDatabase->watchPeriod()/60 ; }
|
int ftServer::watchPeriod() const { return mFileDatabase->watchPeriod()/60 ; }
|
||||||
bool ftServer::followSymLinks() const { return mFileDatabase->followSymLinks() ; }
|
bool ftServer::followSymLinks() const { return mFileDatabase->followSymLinks() ; }
|
||||||
|
bool ftServer::ignoreDuplicates() { return mFileDatabase->ignoreDuplicates() ; }
|
||||||
|
int ftServer::maxShareDepth() const { return mFileDatabase->maxShareDepth() ; }
|
||||||
|
|
||||||
void ftServer::setWatchEnabled(bool b) { mFileDatabase->setWatchEnabled(b) ; }
|
void ftServer::setWatchEnabled(bool b) { mFileDatabase->setWatchEnabled(b) ; }
|
||||||
void ftServer::setWatchPeriod(int minutes) { mFileDatabase->setWatchPeriod(minutes*60) ; }
|
void ftServer::setWatchPeriod(int minutes) { mFileDatabase->setWatchPeriod(minutes*60) ; }
|
||||||
void ftServer::setFollowSymLinks(bool b) { mFileDatabase->setFollowSymLinks(b) ; }
|
void ftServer::setFollowSymLinks(bool b) { mFileDatabase->setFollowSymLinks(b) ; }
|
||||||
|
void ftServer::setIgnoreDuplicates(bool ignore) { mFileDatabase->setIgnoreDuplicates(ignore); }
|
||||||
|
void ftServer::setMaxShareDepth(int depth) { mFileDatabase->setMaxShareDepth(depth) ; }
|
||||||
|
|
||||||
void ftServer::togglePauseHashingProcess() { mFileDatabase->togglePauseHashingProcess() ; }
|
void ftServer::togglePauseHashingProcess() { mFileDatabase->togglePauseHashingProcess() ; }
|
||||||
bool ftServer::hashingProcessPaused() { return mFileDatabase->hashingProcessPaused() ; }
|
bool ftServer::hashingProcessPaused() { return mFileDatabase->hashingProcessPaused() ; }
|
||||||
|
@ -228,6 +228,12 @@ public:
|
|||||||
virtual void togglePauseHashingProcess();
|
virtual void togglePauseHashingProcess();
|
||||||
virtual bool hashingProcessPaused();
|
virtual bool hashingProcessPaused();
|
||||||
|
|
||||||
|
virtual void setMaxShareDepth(int depth) ;
|
||||||
|
virtual int maxShareDepth() const;
|
||||||
|
|
||||||
|
virtual bool ignoreDuplicates() ;
|
||||||
|
virtual void setIgnoreDuplicates(bool ignore) ;
|
||||||
|
|
||||||
/***************************************************************/
|
/***************************************************************/
|
||||||
/*************** Data Transfer Interface ***********************/
|
/*************** Data Transfer Interface ***********************/
|
||||||
/***************************************************************/
|
/***************************************************************/
|
||||||
|
@ -60,8 +60,11 @@ const uint32_t RS_FILE_RATE_STREAM_VIDEO = 0x00000006;
|
|||||||
const uint32_t RS_FILE_PEER_ONLINE = 0x00001000;
|
const uint32_t RS_FILE_PEER_ONLINE = 0x00001000;
|
||||||
const uint32_t RS_FILE_PEER_OFFLINE = 0x00002000;
|
const uint32_t RS_FILE_PEER_OFFLINE = 0x00002000;
|
||||||
|
|
||||||
const uint32_t RS_FILE_SHARE_FLAGS_IGNORE_PREFIXES = 0x0001 ;
|
const uint32_t RS_FILE_SHARE_FLAGS_IGNORE_PREFIXES = 0x0001 ;
|
||||||
const uint32_t RS_FILE_SHARE_FLAGS_IGNORE_SUFFIXES = 0x0002 ;
|
const uint32_t RS_FILE_SHARE_FLAGS_IGNORE_SUFFIXES = 0x0002 ;
|
||||||
|
const uint32_t RS_FILE_SHARE_FLAGS_IGNORE_DUPLICATES = 0x0004 ;
|
||||||
|
|
||||||
|
const uint32_t RS_FILE_SHARE_PARAMETER_DEFAULT_MAXIMUM_DEPTH = 8;
|
||||||
|
|
||||||
/************************************
|
/************************************
|
||||||
* Used To indicate where to search.
|
* Used To indicate where to search.
|
||||||
@ -269,6 +272,12 @@ class RsFiles
|
|||||||
virtual bool getShareDownloadDirectory() = 0;
|
virtual bool getShareDownloadDirectory() = 0;
|
||||||
virtual bool shareDownloadDirectory(bool share) = 0;
|
virtual bool shareDownloadDirectory(bool share) = 0;
|
||||||
|
|
||||||
|
virtual void setMaxShareDepth(int depth) =0;
|
||||||
|
virtual int maxShareDepth() const=0;
|
||||||
|
|
||||||
|
virtual bool ignoreDuplicates() = 0;
|
||||||
|
virtual void setIgnoreDuplicates(bool ignore) = 0;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -59,6 +59,8 @@ TransferPage::TransferPage(QWidget * parent, Qt::WindowFlags flags)
|
|||||||
QObject::connect(ui.prefixesIgnoreList_CB, SIGNAL(toggled(bool)), this,SLOT(updateIgnoreLists())) ;
|
QObject::connect(ui.prefixesIgnoreList_CB, SIGNAL(toggled(bool)), this,SLOT(updateIgnoreLists())) ;
|
||||||
QObject::connect(ui.suffixesIgnoreList_LE, SIGNAL(editingFinished()), this,SLOT(updateIgnoreLists())) ;
|
QObject::connect(ui.suffixesIgnoreList_LE, SIGNAL(editingFinished()), this,SLOT(updateIgnoreLists())) ;
|
||||||
QObject::connect(ui.suffixesIgnoreList_CB, SIGNAL(toggled(bool)), this,SLOT(updateIgnoreLists())) ;
|
QObject::connect(ui.suffixesIgnoreList_CB, SIGNAL(toggled(bool)), this,SLOT(updateIgnoreLists())) ;
|
||||||
|
QObject::connect(ui.ignoreDuplicates_CB, SIGNAL(toggled(bool)), this,SLOT(updateIgnoreDuplicates())) ;
|
||||||
|
QObject::connect(ui.maxDepth_SB, SIGNAL(valueChanged(int)), this,SLOT(updateMaxShareDepth(int))) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TransferPage::updateIgnoreLists()
|
void TransferPage::updateIgnoreLists()
|
||||||
@ -116,6 +118,8 @@ void TransferPage::updateFilePermDirectDL(int i)
|
|||||||
|
|
||||||
void TransferPage::load()
|
void TransferPage::load()
|
||||||
{
|
{
|
||||||
|
ui.ignoreDuplicates_CB->setEnabled(rsFiles->followSymLinks()) ;
|
||||||
|
|
||||||
whileBlocking(ui.shareDownloadDirectoryCB)->setChecked(rsFiles->getShareDownloadDirectory());
|
whileBlocking(ui.shareDownloadDirectoryCB)->setChecked(rsFiles->getShareDownloadDirectory());
|
||||||
|
|
||||||
int u = rsFiles->watchPeriod() ;
|
int u = rsFiles->watchPeriod() ;
|
||||||
@ -125,6 +129,8 @@ void TransferPage::load()
|
|||||||
whileBlocking(ui.incomingDir)->setText(QString::fromUtf8(rsFiles->getDownloadDirectory().c_str()));
|
whileBlocking(ui.incomingDir)->setText(QString::fromUtf8(rsFiles->getDownloadDirectory().c_str()));
|
||||||
whileBlocking(ui.partialsDir)->setText(QString::fromUtf8(rsFiles->getPartialsDirectory().c_str()));
|
whileBlocking(ui.partialsDir)->setText(QString::fromUtf8(rsFiles->getPartialsDirectory().c_str()));
|
||||||
whileBlocking(ui.followSymLinks_CB)->setChecked(rsFiles->followSymLinks());
|
whileBlocking(ui.followSymLinks_CB)->setChecked(rsFiles->followSymLinks());
|
||||||
|
whileBlocking(ui.ignoreDuplicates_CB)->setChecked(rsFiles->ignoreDuplicates());
|
||||||
|
whileBlocking(ui.maxDepth_SB)->setValue(rsFiles->maxShareDepth());
|
||||||
|
|
||||||
whileBlocking(ui._queueSize_SB)->setValue(rsFiles->getQueueSize()) ;
|
whileBlocking(ui._queueSize_SB)->setValue(rsFiles->getQueueSize()) ;
|
||||||
|
|
||||||
@ -199,6 +205,14 @@ void TransferPage::updateDiskSizeLimit(int s)
|
|||||||
{
|
{
|
||||||
rsFiles->setFreeDiskSpaceLimit(s) ;
|
rsFiles->setFreeDiskSpaceLimit(s) ;
|
||||||
}
|
}
|
||||||
|
void TransferPage::updateIgnoreDuplicates()
|
||||||
|
{
|
||||||
|
rsFiles->setIgnoreDuplicates(ui.ignoreDuplicates_CB->isChecked());
|
||||||
|
}
|
||||||
|
void TransferPage::updateMaxShareDepth(int s)
|
||||||
|
{
|
||||||
|
rsFiles->setMaxShareDepth(s) ;
|
||||||
|
}
|
||||||
|
|
||||||
void TransferPage::updateQueueSize(int s)
|
void TransferPage::updateQueueSize(int s)
|
||||||
{
|
{
|
||||||
@ -243,4 +257,4 @@ void TransferPage::editDirectories()
|
|||||||
void TransferPage::updateAutoCheckDirectories() { rsFiles->setWatchEnabled(ui.autoCheckDirectories_CB->isChecked()) ; }
|
void TransferPage::updateAutoCheckDirectories() { rsFiles->setWatchEnabled(ui.autoCheckDirectories_CB->isChecked()) ; }
|
||||||
void TransferPage::updateAutoScanDirectoriesPeriod() { rsFiles->setWatchPeriod(ui.autoCheckDirectoriesDelay_SB->value()); }
|
void TransferPage::updateAutoScanDirectoriesPeriod() { rsFiles->setWatchPeriod(ui.autoCheckDirectoriesDelay_SB->value()); }
|
||||||
void TransferPage::updateShareDownloadDirectory() { rsFiles->shareDownloadDirectory(ui.shareDownloadDirectoryCB->isChecked());}
|
void TransferPage::updateShareDownloadDirectory() { rsFiles->shareDownloadDirectory(ui.shareDownloadDirectoryCB->isChecked());}
|
||||||
void TransferPage::updateFollowSymLinks() { rsFiles->setFollowSymLinks(ui.followSymLinks_CB->isChecked()); }
|
void TransferPage::updateFollowSymLinks() { rsFiles->setFollowSymLinks(ui.followSymLinks_CB->isChecked()); ui.ignoreDuplicates_CB->setEnabled(ui.followSymLinks_CB->isChecked());}
|
||||||
|
@ -51,6 +51,7 @@ class TransferPage: public ConfigPage
|
|||||||
void updateMaxUploadSlots(int);
|
void updateMaxUploadSlots(int);
|
||||||
void updateFilePermDirectDL(int);
|
void updateFilePermDirectDL(int);
|
||||||
void updateIgnoreLists();
|
void updateIgnoreLists();
|
||||||
|
void updateMaxShareDepth(int);
|
||||||
|
|
||||||
void editDirectories() ;
|
void editDirectories() ;
|
||||||
void setIncomingDirectory();
|
void setIncomingDirectory();
|
||||||
@ -61,6 +62,7 @@ class TransferPage: public ConfigPage
|
|||||||
void updateAutoScanDirectoriesPeriod() ;
|
void updateAutoScanDirectoriesPeriod() ;
|
||||||
void updateShareDownloadDirectory() ;
|
void updateShareDownloadDirectory() ;
|
||||||
void updateFollowSymLinks() ;
|
void updateFollowSymLinks() ;
|
||||||
|
void updateIgnoreDuplicates() ;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
@ -6,8 +6,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>1126</width>
|
<width>1312</width>
|
||||||
<height>1103</height>
|
<height>1305</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="TransferPageVLayout">
|
<layout class="QVBoxLayout" name="TransferPageVLayout">
|
||||||
@ -18,33 +18,35 @@
|
|||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="shareDownloadHLayout">
|
<widget class="QPushButton" name="editShareButton">
|
||||||
<item>
|
<property name="text">
|
||||||
<widget class="QCheckBox" name="shareDownloadDirectoryCB">
|
<string>Edit Share</string>
|
||||||
<property name="enabled">
|
</property>
|
||||||
<bool>true</bool>
|
</widget>
|
||||||
</property>
|
</item>
|
||||||
<property name="text">
|
<item>
|
||||||
<string>Automatically share incoming directory (Recommended)</string>
|
<widget class="QCheckBox" name="shareDownloadDirectoryCB">
|
||||||
</property>
|
<property name="enabled">
|
||||||
<property name="checked">
|
<bool>true</bool>
|
||||||
<bool>true</bool>
|
</property>
|
||||||
</property>
|
<property name="text">
|
||||||
</widget>
|
<string>Automatically share incoming directory (Recommended)</string>
|
||||||
</item>
|
</property>
|
||||||
<item>
|
<property name="checked">
|
||||||
<widget class="QPushButton" name="editShareButton">
|
<bool>true</bool>
|
||||||
<property name="text">
|
</property>
|
||||||
<string>Edit Share</string>
|
</widget>
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="autoCheckDirectoriesHLayout">
|
<layout class="QHBoxLayout" name="autoCheckDirectoriesHLayout">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QCheckBox" name="autoCheckDirectories_CB">
|
<widget class="QCheckBox" name="autoCheckDirectories_CB">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Auto-check shared directories every </string>
|
<string>Auto-check shared directories every </string>
|
||||||
</property>
|
</property>
|
||||||
@ -88,6 +90,37 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="ignoreDuplicates_CB">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string><html><head/><body><p>When following sybolic links, Retroshare can encounter the same directory/file more than once. If checked, this option will make tell Retroshare to silently ignore the file. This option saves Retroshare indexing against directory loops.</p></body></html></string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Ignore duplicate files/directories</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label">
|
||||||
|
<property name="text">
|
||||||
|
<string>Maximum depth (0=unlimited):</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QSpinBox" name="maxDepth_SB">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string><html><head/><body><p>This value allows you to limit the depth of the directory hierarchy you are indexing, starting from the base directory. If you allow Retroshare to follow symbolic links and unchecked &quot;Ignore duplicate files/directories&quot;, this option will avoid that Retroshare loops indefinitly while parsing directories.</p></body></html></string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||||
<item>
|
<item>
|
||||||
@ -132,47 +165,57 @@
|
|||||||
<property name="title">
|
<property name="title">
|
||||||
<string>Incoming Directory</string>
|
<string>Incoming Directory</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="incomingGBoxGLayout">
|
<widget class="QLineEdit" name="incomingDir">
|
||||||
<item row="0" column="0">
|
<property name="geometry">
|
||||||
<widget class="QLineEdit" name="incomingDir">
|
<rect>
|
||||||
<property name="readOnly">
|
<x>21</x>
|
||||||
<bool>true</bool>
|
<y>52</y>
|
||||||
</property>
|
<width>244</width>
|
||||||
</widget>
|
<height>36</height>
|
||||||
</item>
|
</rect>
|
||||||
<item row="0" column="1">
|
</property>
|
||||||
<widget class="QPushButton" name="incomingButton">
|
<property name="readOnly">
|
||||||
<property name="minimumSize">
|
<bool>true</bool>
|
||||||
<size>
|
</property>
|
||||||
<width>31</width>
|
</widget>
|
||||||
<height>31</height>
|
<widget class="QPushButton" name="incomingButton">
|
||||||
</size>
|
<property name="geometry">
|
||||||
</property>
|
<rect>
|
||||||
<property name="maximumSize">
|
<x>1224</x>
|
||||||
<size>
|
<y>54</y>
|
||||||
<width>31</width>
|
<width>31</width>
|
||||||
<height>31</height>
|
<height>31</height>
|
||||||
</size>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="toolTip">
|
<property name="minimumSize">
|
||||||
<string>Browse</string>
|
<size>
|
||||||
</property>
|
<width>31</width>
|
||||||
<property name="text">
|
<height>31</height>
|
||||||
<string/>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="icon">
|
<property name="maximumSize">
|
||||||
<iconset resource="../images.qrc">
|
<size>
|
||||||
<normaloff>:/images/directoryselect_24x24_shadow.png</normaloff>:/images/directoryselect_24x24_shadow.png</iconset>
|
<width>31</width>
|
||||||
</property>
|
<height>31</height>
|
||||||
<property name="iconSize">
|
</size>
|
||||||
<size>
|
</property>
|
||||||
<width>24</width>
|
<property name="toolTip">
|
||||||
<height>24</height>
|
<string>Browse</string>
|
||||||
</size>
|
</property>
|
||||||
</property>
|
<property name="text">
|
||||||
</widget>
|
<string/>
|
||||||
</item>
|
</property>
|
||||||
</layout>
|
<property name="icon">
|
||||||
|
<iconset resource="../images.qrc">
|
||||||
|
<normaloff>:/images/directoryselect_24x24_shadow.png</normaloff>:/images/directoryselect_24x24_shadow.png</iconset>
|
||||||
|
</property>
|
||||||
|
<property name="iconSize">
|
||||||
|
<size>
|
||||||
|
<width>24</width>
|
||||||
|
<height>24</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
|
Loading…
Reference in New Issue
Block a user