mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-22 15:51:29 -04:00
added optional delay to check files after download in order to prevent skiping recently downloaded files
This commit is contained in:
parent
0efc6b00a1
commit
10bee9f26b
9 changed files with 18 additions and 14 deletions
|
@ -107,10 +107,13 @@ void LocalDirectoryUpdater::threadTick()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LocalDirectoryUpdater::forceUpdate()
|
void LocalDirectoryUpdater::forceUpdate(bool add_safe_delay)
|
||||||
{
|
{
|
||||||
mForceUpdate = true ;
|
mForceUpdate = true ;
|
||||||
mLastSweepTime = 0 ;
|
mLastSweepTime = rstime_t(time(NULL)) - rstime_t(mDelayBetweenDirectoryUpdates) ;
|
||||||
|
|
||||||
|
if(add_safe_delay)
|
||||||
|
mLastSweepTime += rstime_t(MIN_TIME_AFTER_LAST_MODIFICATION);
|
||||||
|
|
||||||
if(mHashCache != NULL && mHashCache->hashingProcessPaused())
|
if(mHashCache != NULL && mHashCache->hashingProcessPaused())
|
||||||
mHashCache->togglePauseHashingProcess();
|
mHashCache->togglePauseHashingProcess();
|
||||||
|
@ -363,7 +366,7 @@ void LocalDirectoryUpdater::setFollowSymLinks(bool b)
|
||||||
|
|
||||||
mFollowSymLinks = b ;
|
mFollowSymLinks = b ;
|
||||||
|
|
||||||
forceUpdate();
|
forceUpdate(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LocalDirectoryUpdater::followSymLinks() const
|
bool LocalDirectoryUpdater::followSymLinks() const
|
||||||
|
|
|
@ -35,7 +35,7 @@ public:
|
||||||
LocalDirectoryUpdater(HashStorage *hash_cache,LocalDirectoryStorage *lds) ;
|
LocalDirectoryUpdater(HashStorage *hash_cache,LocalDirectoryStorage *lds) ;
|
||||||
virtual ~LocalDirectoryUpdater() {}
|
virtual ~LocalDirectoryUpdater() {}
|
||||||
|
|
||||||
void forceUpdate();
|
void forceUpdate(bool add_safe_delay);
|
||||||
bool inDirectoryCheck() const ;
|
bool inDirectoryCheck() const ;
|
||||||
void togglePauseHashingProcess();
|
void togglePauseHashingProcess();
|
||||||
bool hashingProcessPaused();
|
bool hashingProcessPaused();
|
||||||
|
|
|
@ -48,7 +48,7 @@ static const std::string LOCAL_SHARED_DIRS_FILE_NAME = "local_dir_hierarchy.bin"
|
||||||
|
|
||||||
static const uint32_t MIN_INTERVAL_BETWEEN_HASH_CACHE_SAVE = 20 ; // never save hash cache more often than every 20 secs.
|
static const uint32_t MIN_INTERVAL_BETWEEN_HASH_CACHE_SAVE = 20 ; // never save hash cache more often than every 20 secs.
|
||||||
static const uint32_t MIN_INTERVAL_BETWEEN_REMOTE_DIRECTORY_SAVE = 23 ; // never save remote directories more often than this
|
static const uint32_t MIN_INTERVAL_BETWEEN_REMOTE_DIRECTORY_SAVE = 23 ; // never save remote directories more often than this
|
||||||
static const uint32_t MIN_TIME_AFTER_LAST_MODIFICATION = 20 ; // never hash a file that is just being modified, otherwise we end up with a corrupted hash
|
static const uint32_t MIN_TIME_AFTER_LAST_MODIFICATION = 10 ; // never hash a file that is just being modified, otherwise we end up with a corrupted hash
|
||||||
|
|
||||||
static const uint32_t MAX_DIR_SYNC_RESPONSE_DATA_SIZE = 20000 ; // Maximum RsItem data size in bytes for serialised directory transmission
|
static const uint32_t MAX_DIR_SYNC_RESPONSE_DATA_SIZE = 20000 ; // Maximum RsItem data size in bytes for serialised directory transmission
|
||||||
static const uint32_t DEFAULT_HASH_STORAGE_DURATION_DAYS = 30 ; // remember deleted/inaccessible files for 30 days
|
static const uint32_t DEFAULT_HASH_STORAGE_DURATION_DAYS = 30 ; // remember deleted/inaccessible files for 30 days
|
||||||
|
|
|
@ -114,7 +114,7 @@ void p3FileDatabase::setSharedDirectories(const std::list<SharedDirInfo>& shared
|
||||||
RS_STACK_MUTEX(mFLSMtx) ;
|
RS_STACK_MUTEX(mFLSMtx) ;
|
||||||
|
|
||||||
mLocalSharedDirs->setSharedDirectoryList(shared_dirs) ;
|
mLocalSharedDirs->setSharedDirectoryList(shared_dirs) ;
|
||||||
mLocalDirWatcher->forceUpdate();
|
mLocalDirWatcher->forceUpdate(false);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1231,9 +1231,9 @@ uint32_t p3FileDatabase::getType(void *ref,FileSearchFlags flags) const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void p3FileDatabase::forceDirectoryCheck() // Force re-sweep the directories and see what's changed
|
void p3FileDatabase::forceDirectoryCheck(bool add_safe_delay) // Force re-sweep the directories and see what's changed
|
||||||
{
|
{
|
||||||
mLocalDirWatcher->forceUpdate();
|
mLocalDirWatcher->forceUpdate(add_safe_delay);
|
||||||
}
|
}
|
||||||
void p3FileDatabase::togglePauseHashingProcess()
|
void p3FileDatabase::togglePauseHashingProcess()
|
||||||
{
|
{
|
||||||
|
|
|
@ -168,7 +168,7 @@ class p3FileDatabase: public p3Service, public p3Config, public ftSearch //, pub
|
||||||
|
|
||||||
// interfact for directory parsing
|
// interfact for directory parsing
|
||||||
|
|
||||||
void forceDirectoryCheck(); // Force re-sweep the directories and see what's changed
|
void forceDirectoryCheck(bool add_safe_delay); // Force re-sweep the directories and see what's changed
|
||||||
bool inDirectoryCheck();
|
bool inDirectoryCheck();
|
||||||
void togglePauseHashingProcess();
|
void togglePauseHashingProcess();
|
||||||
bool hashingProcessPaused();
|
bool hashingProcessPaused();
|
||||||
|
|
|
@ -821,7 +821,7 @@ bool ftController::completeFile(const RsFileHash& hash)
|
||||||
RsServer::notify()->notifyDownloadComplete(hash.toStdString());
|
RsServer::notify()->notifyDownloadComplete(hash.toStdString());
|
||||||
RsServer::notify()->notifyDownloadCompleteCount(completeCount);
|
RsServer::notify()->notifyDownloadCompleteCount(completeCount);
|
||||||
|
|
||||||
rsFiles->ForceDirectoryCheck() ;
|
rsFiles->ForceDirectoryCheck(true) ;
|
||||||
|
|
||||||
IndicateConfigChanged(); /* completed transfer -> save */
|
IndicateConfigChanged(); /* completed transfer -> save */
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -791,9 +791,9 @@ void ftServer::updateSinceGroupPermissionsChanged()
|
||||||
{
|
{
|
||||||
mFileDatabase->forceSyncWithPeers();
|
mFileDatabase->forceSyncWithPeers();
|
||||||
}
|
}
|
||||||
void ftServer::ForceDirectoryCheck()
|
void ftServer::ForceDirectoryCheck(bool add_safe_delay)
|
||||||
{
|
{
|
||||||
mFileDatabase->forceDirectoryCheck();
|
mFileDatabase->forceDirectoryCheck(add_safe_delay);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -275,7 +275,7 @@ public:
|
||||||
* Utility Functions
|
* Utility Functions
|
||||||
***/
|
***/
|
||||||
virtual bool ConvertSharedFilePath(std::string path, std::string &fullpath);
|
virtual bool ConvertSharedFilePath(std::string path, std::string &fullpath);
|
||||||
virtual void ForceDirectoryCheck();
|
virtual void ForceDirectoryCheck(bool add_safe_delay);
|
||||||
virtual void updateSinceGroupPermissionsChanged() ;
|
virtual void updateSinceGroupPermissionsChanged() ;
|
||||||
virtual bool InDirectoryCheck();
|
virtual bool InDirectoryCheck();
|
||||||
virtual bool copyFile(const std::string& source, const std::string& dest);
|
virtual bool copyFile(const std::string& source, const std::string& dest);
|
||||||
|
|
|
@ -591,9 +591,10 @@ public:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Force shared directories check
|
* @brief Force shared directories check
|
||||||
|
* @param[in] add_safe_delay Schedule the check 20 seconds from now, to ensure to capture files written just now.
|
||||||
* @jsonapi{development}
|
* @jsonapi{development}
|
||||||
*/
|
*/
|
||||||
virtual void ForceDirectoryCheck() = 0;
|
virtual void ForceDirectoryCheck(bool add_safe_delay=false) = 0;
|
||||||
|
|
||||||
virtual void updateSinceGroupPermissionsChanged() = 0;
|
virtual void updateSinceGroupPermissionsChanged() = 0;
|
||||||
virtual bool InDirectoryCheck() = 0;
|
virtual bool InDirectoryCheck() = 0;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue