mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-08-09 23:02:29 -04:00
added squeleton code for own directory update
This commit is contained in:
parent
3bf3d0c360
commit
3c976bb7ee
6 changed files with 248 additions and 54 deletions
|
@ -1,29 +1,50 @@
|
|||
#pragma once
|
||||
|
||||
#include <map>
|
||||
#include "util/rsthreads.h"
|
||||
|
||||
class HashCache
|
||||
{
|
||||
public:
|
||||
HashCache(const std::string& save_file_name) ;
|
||||
public:
|
||||
HashCache(const std::string& save_file_name) ;
|
||||
|
||||
void save() ;
|
||||
void insert(const std::string& full_path,uint64_t size,time_t time_stamp,const RsFileHash& hash) ;
|
||||
bool find(const std::string& full_path,uint64_t size,time_t time_stamp,RsFileHash& hash) ;
|
||||
void clean() ;
|
||||
void insert(const std::string& full_path,uint64_t size,time_t time_stamp,const RsFileHash& hash) ;
|
||||
bool find(const std::string& full_path,uint64_t size,time_t time_stamp,RsFileHash& hash) ;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint64_t size ;
|
||||
uint64_t time_stamp ;
|
||||
uint64_t modf_stamp ;
|
||||
RsFileHash hash ;
|
||||
} HashCacheInfo ;
|
||||
struct HashCacheInfo
|
||||
{
|
||||
std::string filename ;
|
||||
uint64_t size ;
|
||||
uint32_t time_stamp ;
|
||||
uint32_t modf_stamp ;
|
||||
RsFileHash hash ;
|
||||
} ;
|
||||
|
||||
void setRememberHashFilesDuration(uint32_t days) { _max_cache_duration_days = days ; }
|
||||
uint32_t rememberHashFilesDuration() const { return _max_cache_duration_days ; }
|
||||
void clear() { _files.clear(); }
|
||||
bool empty() const { return _files.empty() ; }
|
||||
private:
|
||||
uint32_t _max_cache_duration_days ; // maximum duration of un-requested cache entries
|
||||
std::map<std::string, HashCacheInfo> _files ;
|
||||
std::string _path ;
|
||||
bool _changed ;
|
||||
// interaction with GUI, called from p3FileLists
|
||||
void setRememberHashFilesDuration(uint32_t days) { _max_cache_duration_days = days ; }
|
||||
uint32_t rememberHashFilesDuration() const { return _max_cache_duration_days ; }
|
||||
void clear() { _files.clear(); }
|
||||
bool empty() const { return _files.empty() ; }
|
||||
|
||||
private:
|
||||
void clean() ;
|
||||
|
||||
void save() ;
|
||||
void load() ;
|
||||
|
||||
// threaded stuff
|
||||
RsTickingThread mHashingThread ;
|
||||
RsMutex mHashMtx ;
|
||||
|
||||
// Local configuration and storage
|
||||
|
||||
uint32_t mMaxCacheDurationDays ; // maximum duration of un-requested cache entries
|
||||
std::map<std::string, HashCacheInfo> mFiles ;
|
||||
std::string mFilePath ;
|
||||
bool mChanged ;
|
||||
|
||||
// current work
|
||||
|
||||
std::map<std::string> mFilesToHash ;
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue