44 lines
1.3 KiB
C
Raw Normal View History

// 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"
#include "file_sharing/directory_storage.h"
class DirectoryUpdater
{
public:
DirectoryUpdater() {}
virtual ~DirectoryUpdater(){}
};
2016-07-28 10:49:49 +02:00
class LocalDirectoryUpdater: public DirectoryUpdater, public HashStorageClient, public RsTickingThread
{
public:
2016-07-28 00:48:28 +02:00
LocalDirectoryUpdater(HashStorage *hash_cache,LocalDirectoryStorage *lds) ;
virtual ~LocalDirectoryUpdater() {}
2016-07-28 10:49:49 +02:00
virtual void data_tick() ;
2016-07-23 22:14:43 -04:00
protected:
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
private:
HashStorage *mHashCache ;
LocalDirectoryStorage *mSharedDirectories ;
2016-07-28 10:49:49 +02:00
time_t mLastSweepTime;
};
class RemoteDirectoryUpdater: public DirectoryUpdater
{
public:
RemoteDirectoryUpdater() {}
virtual ~RemoteDirectoryUpdater() {}
virtual void tick() ;
};