2016-04-14 18:25:12 -04:00
|
|
|
// This class crawls the given directry hierarchy and updates it. It does so by calling the
|
|
|
|
// shared file list source. This source may be of two types:
|
|
|
|
// - local: directories are crawled n disk and files are hashed / requested from a cache
|
|
|
|
// - remote: directories are requested remotely to a providing client
|
|
|
|
//
|
2016-07-23 22:14:43 -04:00
|
|
|
#include "file_sharing/hash_cache.h"
|
2016-07-24 23:48:22 -04:00
|
|
|
#include "file_sharing/directory_storage.h"
|
2016-07-21 00:16:12 -04:00
|
|
|
|
2016-09-02 21:49:43 +02:00
|
|
|
class LocalDirectoryUpdater: public HashStorageClient, public RsTickingThread
|
2016-04-14 18:25:12 -04:00
|
|
|
{
|
2016-07-21 00:16:12 -04:00
|
|
|
public:
|
2016-07-28 00:48:28 +02:00
|
|
|
LocalDirectoryUpdater(HashStorage *hash_cache,LocalDirectoryStorage *lds) ;
|
2016-07-24 23:48:22 -04:00
|
|
|
virtual ~LocalDirectoryUpdater() {}
|
|
|
|
|
2016-08-06 19:04:54 +02:00
|
|
|
virtual void forceUpdate();
|
2016-07-21 00:16:12 -04:00
|
|
|
|
2016-09-01 21:04:48 +02:00
|
|
|
void setFileWatchPeriod(uint32_t seconds) { mDelayBetweenDirectoryUpdates = seconds ; }
|
|
|
|
uint32_t fileWatchPeriod() const { return mDelayBetweenDirectoryUpdates ; }
|
|
|
|
|
2016-07-23 22:14:43 -04:00
|
|
|
protected:
|
2016-08-06 19:04:54 +02:00
|
|
|
virtual void data_tick() ;
|
|
|
|
|
2016-07-27 21:22:59 +02:00
|
|
|
virtual void hash_callback(uint32_t client_param, const std::string& name, const RsFileHash& hash, uint64_t size);
|
2016-07-23 22:14:43 -04:00
|
|
|
void recursUpdateSharedDir(const std::string& cumulated_path,DirectoryStorage::EntryIndex indx);
|
2016-07-28 10:49:49 +02:00
|
|
|
void sweepSharedDirectories();
|
2016-07-23 22:14:43 -04:00
|
|
|
|
2016-07-21 00:16:12 -04:00
|
|
|
private:
|
2016-07-27 21:22:59 +02:00
|
|
|
HashStorage *mHashCache ;
|
2016-07-21 00:16:12 -04:00
|
|
|
LocalDirectoryStorage *mSharedDirectories ;
|
2016-07-28 10:49:49 +02:00
|
|
|
|
|
|
|
time_t mLastSweepTime;
|
2016-08-22 07:49:45 +02:00
|
|
|
time_t mLastTSUpdateTime;
|
2016-09-01 21:04:48 +02:00
|
|
|
|
|
|
|
uint32_t mDelayBetweenDirectoryUpdates;
|
2016-04-14 18:25:12 -04:00
|
|
|
};
|
|
|
|
|