mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-11 18:45:17 -04:00
Merge branch 'master' into jsonapi
This commit is contained in:
commit
047ae7f723
260 changed files with 1737 additions and 1178 deletions
|
@ -90,10 +90,10 @@ Classes
|
|||
- std::string name
|
||||
- RsFileHash hash
|
||||
- uint64_t size
|
||||
- time_t Last modification time
|
||||
- rstime_t Last modification time
|
||||
|
||||
LocalFileInfo: public FileInfo
|
||||
- time_t Last data access time
|
||||
- rstime_t Last data access time
|
||||
- uint64_t Total data uploaded
|
||||
- uint32_t ShareFlags
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
******************************************************************************/
|
||||
#include <sstream>
|
||||
#include <algorithm>
|
||||
#include <time.h>
|
||||
#include "util/rstime.h"
|
||||
#include "util/rsdir.h"
|
||||
#include "util/rsprint.h"
|
||||
#include "retroshare/rsexpr.h"
|
||||
|
@ -356,7 +356,7 @@ bool InternalFileHierarchyStorage::updateHash(const DirectoryStorage::EntryIndex
|
|||
|
||||
return true;
|
||||
}
|
||||
bool InternalFileHierarchyStorage::updateFile(const DirectoryStorage::EntryIndex& file_index,const RsFileHash& hash, const std::string& fname,uint64_t size, const time_t modf_time)
|
||||
bool InternalFileHierarchyStorage::updateFile(const DirectoryStorage::EntryIndex& file_index,const RsFileHash& hash, const std::string& fname,uint64_t size, const rstime_t modf_time)
|
||||
{
|
||||
if(!checkIndex(file_index,FileStorageNode::TYPE_FILE))
|
||||
{
|
||||
|
@ -427,7 +427,7 @@ DirectoryStorage::EntryIndex InternalFileHierarchyStorage::allocateNewIndex()
|
|||
return mNodes.size()-1 ;
|
||||
}
|
||||
|
||||
bool InternalFileHierarchyStorage::updateDirEntry(const DirectoryStorage::EntryIndex& indx,const std::string& dir_name,time_t most_recent_time,time_t dir_modtime,const std::vector<RsFileHash>& subdirs_hash,const std::vector<FileEntry>& subfiles_array)
|
||||
bool InternalFileHierarchyStorage::updateDirEntry(const DirectoryStorage::EntryIndex& indx,const std::string& dir_name,rstime_t most_recent_time,rstime_t dir_modtime,const std::vector<RsFileHash>& subdirs_hash,const std::vector<FileEntry>& subfiles_array)
|
||||
{
|
||||
if(!checkIndex(indx,FileStorageNode::TYPE_DIR))
|
||||
{
|
||||
|
@ -599,7 +599,7 @@ void InternalFileHierarchyStorage::getStatistics(SharedDirStats& stats) const
|
|||
stats.total_shared_size = mTotalSize ;
|
||||
}
|
||||
|
||||
bool InternalFileHierarchyStorage::getTS(const DirectoryStorage::EntryIndex& index,time_t& TS,time_t DirEntry::* m) const
|
||||
bool InternalFileHierarchyStorage::getTS(const DirectoryStorage::EntryIndex& index,rstime_t& TS,rstime_t DirEntry::* m) const
|
||||
{
|
||||
if(!checkIndex(index,FileStorageNode::TYPE_DIR))
|
||||
{
|
||||
|
@ -614,7 +614,7 @@ bool InternalFileHierarchyStorage::getTS(const DirectoryStorage::EntryIndex& ind
|
|||
return true;
|
||||
}
|
||||
|
||||
bool InternalFileHierarchyStorage::setTS(const DirectoryStorage::EntryIndex& index,time_t& TS,time_t DirEntry::* m)
|
||||
bool InternalFileHierarchyStorage::setTS(const DirectoryStorage::EntryIndex& index,rstime_t& TS,rstime_t DirEntry::* m)
|
||||
{
|
||||
if(!checkIndex(index,FileStorageNode::TYPE_DIR))
|
||||
{
|
||||
|
@ -631,11 +631,11 @@ bool InternalFileHierarchyStorage::setTS(const DirectoryStorage::EntryIndex& ind
|
|||
|
||||
// Do a complete recursive sweep over sub-directories and files, and update the lst modf TS. This could be also performed by a cleanup method.
|
||||
|
||||
time_t InternalFileHierarchyStorage::recursUpdateLastModfTime(const DirectoryStorage::EntryIndex& dir_index,bool& unfinished_files_present)
|
||||
rstime_t InternalFileHierarchyStorage::recursUpdateLastModfTime(const DirectoryStorage::EntryIndex& dir_index,bool& unfinished_files_present)
|
||||
{
|
||||
DirEntry& d(*static_cast<DirEntry*>(mNodes[dir_index])) ;
|
||||
|
||||
time_t largest_modf_time = d.dir_modtime ;
|
||||
rstime_t largest_modf_time = d.dir_modtime ;
|
||||
unfinished_files_present = false ;
|
||||
|
||||
for(uint32_t i=0;i<d.subfiles.size();++i)
|
||||
|
@ -732,7 +732,7 @@ public:
|
|||
inline virtual const std::string& file_name() const { return mFe.file_name ; }
|
||||
inline virtual uint64_t file_size() const { return mFe.file_size ; }
|
||||
inline virtual const RsFileHash& file_hash() const { return mFe.file_hash ; }
|
||||
inline virtual time_t file_modtime() const { return mFe.file_modtime ; }
|
||||
inline virtual rstime_t file_modtime() const { return mFe.file_modtime ; }
|
||||
inline virtual std::string file_parent_path()const { return RsDirUtil::makePath(mDe.dir_parent_path, mDe.dir_name) ; }
|
||||
inline virtual uint32_t file_popularity() const { NOT_IMPLEMENTED() ; return 0; }
|
||||
|
||||
|
@ -865,7 +865,7 @@ void InternalFileHierarchyStorage::print() const
|
|||
for(uint32_t i=0;i<mNodes.size();++i)
|
||||
if(mNodes[i] == NULL)
|
||||
{
|
||||
std::cerr << " Node " << i << ": empty " << std::endl;
|
||||
//std::cerr << " Node " << i << ": empty " << std::endl;
|
||||
++nempty ;
|
||||
}
|
||||
else if(mNodes[i]->type() == FileStorageNode::TYPE_DIR)
|
||||
|
@ -1183,6 +1183,11 @@ bool InternalFileHierarchyStorage::load(const std::string& fname)
|
|||
}
|
||||
free(buffer) ;
|
||||
|
||||
std::string err_str ;
|
||||
|
||||
if(!check(err_str))
|
||||
std::cerr << "(EE) Error while loading file hierarchy " << fname << std::endl;
|
||||
|
||||
return true ;
|
||||
}
|
||||
catch(read_error& e)
|
||||
|
|
|
@ -47,8 +47,8 @@ public:
|
|||
{
|
||||
public:
|
||||
FileEntry() : file_size(0), file_modtime(0) {}
|
||||
FileEntry(const std::string& name,uint64_t size,time_t modtime) : file_name(name),file_size(size),file_modtime(modtime) {}
|
||||
FileEntry(const std::string& name,uint64_t size,time_t modtime,const RsFileHash& hash) : file_name(name),file_size(size),file_modtime(modtime),file_hash(hash) {}
|
||||
FileEntry(const std::string& name,uint64_t size,rstime_t modtime) : file_name(name),file_size(size),file_modtime(modtime) {}
|
||||
FileEntry(const std::string& name,uint64_t size,rstime_t modtime,const RsFileHash& hash) : file_name(name),file_size(size),file_modtime(modtime),file_hash(hash) {}
|
||||
|
||||
virtual uint32_t type() const { return FileStorageNode::TYPE_FILE ; }
|
||||
virtual ~FileEntry() {}
|
||||
|
@ -56,7 +56,7 @@ public:
|
|||
// local stuff
|
||||
std::string file_name ;
|
||||
uint64_t file_size ;
|
||||
time_t file_modtime;
|
||||
rstime_t file_modtime;
|
||||
RsFileHash file_hash ;
|
||||
};
|
||||
|
||||
|
@ -76,9 +76,9 @@ public:
|
|||
std::vector<DirectoryStorage::EntryIndex> subdirs ;
|
||||
std::vector<DirectoryStorage::EntryIndex> subfiles ;
|
||||
|
||||
time_t dir_modtime;
|
||||
time_t dir_most_recent_time;// recursive most recent modification time, including files and subdirs in the entire hierarchy below.
|
||||
time_t dir_update_time; // last time the information was updated for that directory. Includes subdirs indexes and subfile info.
|
||||
rstime_t dir_modtime;
|
||||
rstime_t dir_most_recent_time;// recursive most recent modification time, including files and subdirs in the entire hierarchy below.
|
||||
rstime_t dir_update_time; // last time the information was updated for that directory. Includes subdirs indexes and subfile info.
|
||||
};
|
||||
|
||||
// class stuff
|
||||
|
@ -95,18 +95,18 @@ public:
|
|||
bool checkIndex(DirectoryStorage::EntryIndex indx,uint8_t type) const;
|
||||
bool updateSubFilesList(const DirectoryStorage::EntryIndex& indx,const std::map<std::string,DirectoryStorage::FileTS>& subfiles,std::map<std::string,DirectoryStorage::FileTS>& new_files);
|
||||
bool updateHash(const DirectoryStorage::EntryIndex& file_index,const RsFileHash& hash);
|
||||
bool updateFile(const DirectoryStorage::EntryIndex& file_index,const RsFileHash& hash, const std::string& fname,uint64_t size, const time_t modf_time);
|
||||
bool updateDirEntry(const DirectoryStorage::EntryIndex& indx, const std::string& dir_name, time_t most_recent_time, time_t dir_modtime, const std::vector<RsFileHash> &subdirs_hash, const std::vector<FileEntry> &subfiles_array);
|
||||
bool updateFile(const DirectoryStorage::EntryIndex& file_index,const RsFileHash& hash, const std::string& fname,uint64_t size, const rstime_t modf_time);
|
||||
bool updateDirEntry(const DirectoryStorage::EntryIndex& indx, const std::string& dir_name, rstime_t most_recent_time, rstime_t dir_modtime, const std::vector<RsFileHash> &subdirs_hash, const std::vector<FileEntry> &subfiles_array);
|
||||
|
||||
// TS get/set functions. Take one of the class members as argument.
|
||||
|
||||
bool getTS(const DirectoryStorage::EntryIndex& index,time_t& TS,time_t DirEntry::* ) const;
|
||||
bool setTS(const DirectoryStorage::EntryIndex& index,time_t& TS,time_t DirEntry::* ) ;
|
||||
bool getTS(const DirectoryStorage::EntryIndex& index,rstime_t& TS,rstime_t DirEntry::* ) const;
|
||||
bool setTS(const DirectoryStorage::EntryIndex& index,rstime_t& TS,rstime_t DirEntry::* ) ;
|
||||
|
||||
// Do a complete recursive sweep over sub-directories and files, and update the lst modf TS. This could be also performed by a cleanup method.
|
||||
// Also keeps the high level statistics up to date.
|
||||
|
||||
time_t recursUpdateLastModfTime(const DirectoryStorage::EntryIndex& dir_index, bool &unfinished_files_present);
|
||||
rstime_t recursUpdateLastModfTime(const DirectoryStorage::EntryIndex& dir_index, bool &unfinished_files_present);
|
||||
|
||||
// hash stuff
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
* *
|
||||
******************************************************************************/
|
||||
#include <set>
|
||||
#include <time.h>
|
||||
#include "util/rstime.h"
|
||||
#include "serialiser/rstlvbinary.h"
|
||||
#include "retroshare/rspeers.h"
|
||||
#include "util/rsdir.h"
|
||||
|
@ -71,7 +71,7 @@ DirectoryStorage::DirIterator ::operator bool() const { return **this != Directo
|
|||
RsFileHash DirectoryStorage::FileIterator::hash() const { const InternalFileHierarchyStorage::FileEntry *f = mStorage->getFileEntry(**this) ; return f?(f->file_hash):RsFileHash(); }
|
||||
uint64_t DirectoryStorage::FileIterator::size() const { const InternalFileHierarchyStorage::FileEntry *f = mStorage->getFileEntry(**this) ; return f?(f->file_size):0; }
|
||||
std::string DirectoryStorage::FileIterator::name() const { const InternalFileHierarchyStorage::FileEntry *f = mStorage->getFileEntry(**this) ; return f?(f->file_name):std::string(); }
|
||||
time_t DirectoryStorage::FileIterator::modtime() const { const InternalFileHierarchyStorage::FileEntry *f = mStorage->getFileEntry(**this) ; return f?(f->file_modtime):0; }
|
||||
rstime_t DirectoryStorage::FileIterator::modtime() const { const InternalFileHierarchyStorage::FileEntry *f = mStorage->getFileEntry(**this) ; return f?(f->file_modtime):0; }
|
||||
|
||||
std::string DirectoryStorage::DirIterator::name() const { const InternalFileHierarchyStorage::DirEntry *d = mStorage->getDirEntry(**this) ; return d?(d->dir_name):std::string(); }
|
||||
|
||||
|
@ -119,13 +119,13 @@ uint32_t DirectoryStorage::getEntryType(const EntryIndex& indx)
|
|||
}
|
||||
}
|
||||
|
||||
bool DirectoryStorage::getDirectoryUpdateTime (EntryIndex index,time_t& update_TS) const { RS_STACK_MUTEX(mDirStorageMtx) ; return mFileHierarchy->getTS(index,update_TS,&InternalFileHierarchyStorage::DirEntry::dir_update_time ); }
|
||||
bool DirectoryStorage::getDirectoryRecursModTime(EntryIndex index,time_t& rec_md_TS) const { RS_STACK_MUTEX(mDirStorageMtx) ; return mFileHierarchy->getTS(index,rec_md_TS,&InternalFileHierarchyStorage::DirEntry::dir_most_recent_time); }
|
||||
bool DirectoryStorage::getDirectoryLocalModTime (EntryIndex index,time_t& loc_md_TS) const { RS_STACK_MUTEX(mDirStorageMtx) ; return mFileHierarchy->getTS(index,loc_md_TS,&InternalFileHierarchyStorage::DirEntry::dir_modtime ); }
|
||||
bool DirectoryStorage::getDirectoryUpdateTime (EntryIndex index,rstime_t& update_TS) const { RS_STACK_MUTEX(mDirStorageMtx) ; return mFileHierarchy->getTS(index,update_TS,&InternalFileHierarchyStorage::DirEntry::dir_update_time ); }
|
||||
bool DirectoryStorage::getDirectoryRecursModTime(EntryIndex index,rstime_t& rec_md_TS) const { RS_STACK_MUTEX(mDirStorageMtx) ; return mFileHierarchy->getTS(index,rec_md_TS,&InternalFileHierarchyStorage::DirEntry::dir_most_recent_time); }
|
||||
bool DirectoryStorage::getDirectoryLocalModTime (EntryIndex index,rstime_t& loc_md_TS) const { RS_STACK_MUTEX(mDirStorageMtx) ; return mFileHierarchy->getTS(index,loc_md_TS,&InternalFileHierarchyStorage::DirEntry::dir_modtime ); }
|
||||
|
||||
bool DirectoryStorage::setDirectoryUpdateTime (EntryIndex index,time_t update_TS) { RS_STACK_MUTEX(mDirStorageMtx) ; return mFileHierarchy->setTS(index,update_TS,&InternalFileHierarchyStorage::DirEntry::dir_update_time ); }
|
||||
bool DirectoryStorage::setDirectoryRecursModTime(EntryIndex index,time_t rec_md_TS) { RS_STACK_MUTEX(mDirStorageMtx) ; return mFileHierarchy->setTS(index,rec_md_TS,&InternalFileHierarchyStorage::DirEntry::dir_most_recent_time); }
|
||||
bool DirectoryStorage::setDirectoryLocalModTime (EntryIndex index,time_t loc_md_TS) { RS_STACK_MUTEX(mDirStorageMtx) ; return mFileHierarchy->setTS(index,loc_md_TS,&InternalFileHierarchyStorage::DirEntry::dir_modtime ); }
|
||||
bool DirectoryStorage::setDirectoryUpdateTime (EntryIndex index,rstime_t update_TS) { RS_STACK_MUTEX(mDirStorageMtx) ; return mFileHierarchy->setTS(index,update_TS,&InternalFileHierarchyStorage::DirEntry::dir_update_time ); }
|
||||
bool DirectoryStorage::setDirectoryRecursModTime(EntryIndex index,rstime_t rec_md_TS) { RS_STACK_MUTEX(mDirStorageMtx) ; return mFileHierarchy->setTS(index,rec_md_TS,&InternalFileHierarchyStorage::DirEntry::dir_most_recent_time); }
|
||||
bool DirectoryStorage::setDirectoryLocalModTime (EntryIndex index,rstime_t loc_md_TS) { RS_STACK_MUTEX(mDirStorageMtx) ; return mFileHierarchy->setTS(index,loc_md_TS,&InternalFileHierarchyStorage::DirEntry::dir_modtime ); }
|
||||
|
||||
bool DirectoryStorage::updateSubDirectoryList(const EntryIndex& indx, const std::set<std::string> &subdirs, const RsFileHash& hash_salt)
|
||||
{
|
||||
|
@ -281,7 +281,7 @@ bool DirectoryStorage::getIndexFromDirHash(const RsFileHash& hash,EntryIndex& in
|
|||
|
||||
void DirectoryStorage::checkSave()
|
||||
{
|
||||
time_t now = time(NULL);
|
||||
rstime_t now = time(NULL);
|
||||
|
||||
if(mChanged && mLastSavedTime + MIN_INTERVAL_BETWEEN_REMOTE_DIRECTORY_SAVE < now)
|
||||
{
|
||||
|
@ -489,7 +489,7 @@ void LocalDirectoryStorage::updateTimeStamps()
|
|||
|
||||
bool unfinished_files_below ;
|
||||
|
||||
time_t last_modf_time = mFileHierarchy->recursUpdateLastModfTime(EntryIndex(0),unfinished_files_below) ;
|
||||
rstime_t last_modf_time = mFileHierarchy->recursUpdateLastModfTime(EntryIndex(0),unfinished_files_below) ;
|
||||
mTSChanged = false ;
|
||||
|
||||
#ifdef DEBUG_LOCAL_DIRECTORY_STORAGE
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
|
||||
#include "retroshare/rsids.h"
|
||||
#include "retroshare/rsfiles.h"
|
||||
#include "util/rstime.h"
|
||||
|
||||
#define NOT_IMPLEMENTED() { std::cerr << __PRETTY_FUNCTION__ << ": not yet implemented." << std::endl; }
|
||||
|
||||
|
@ -52,13 +53,13 @@ class DirectoryStorage
|
|||
|
||||
// gets/sets the various time stamps:
|
||||
//
|
||||
bool getDirectoryRecursModTime(EntryIndex index,time_t& recurs_max_modf_TS) const ; // last modification time, computed recursively over all subfiles and directories
|
||||
bool getDirectoryLocalModTime (EntryIndex index,time_t& motime_TS) const ; // last modification time for that index only
|
||||
bool getDirectoryUpdateTime (EntryIndex index,time_t& update_TS) const ; // last time the entry was updated. This is only used on the RemoteDirectoryStorage side.
|
||||
bool getDirectoryRecursModTime(EntryIndex index,rstime_t& recurs_max_modf_TS) const ; // last modification time, computed recursively over all subfiles and directories
|
||||
bool getDirectoryLocalModTime (EntryIndex index,rstime_t& motime_TS) const ; // last modification time for that index only
|
||||
bool getDirectoryUpdateTime (EntryIndex index,rstime_t& update_TS) const ; // last time the entry was updated. This is only used on the RemoteDirectoryStorage side.
|
||||
|
||||
bool setDirectoryRecursModTime(EntryIndex index,time_t recurs_max_modf_TS) ;
|
||||
bool setDirectoryLocalModTime (EntryIndex index,time_t modtime_TS) ;
|
||||
bool setDirectoryUpdateTime (EntryIndex index,time_t update_TS) ;
|
||||
bool setDirectoryRecursModTime(EntryIndex index,rstime_t recurs_max_modf_TS) ;
|
||||
bool setDirectoryLocalModTime (EntryIndex index,rstime_t modtime_TS) ;
|
||||
bool setDirectoryUpdateTime (EntryIndex index,rstime_t update_TS) ;
|
||||
|
||||
uint32_t getEntryType(const EntryIndex& indx) ; // WARNING: returns DIR_TYPE_*, not the internal directory storage stuff.
|
||||
virtual bool extractData(const EntryIndex& indx,DirDetails& d);
|
||||
|
@ -81,8 +82,8 @@ class DirectoryStorage
|
|||
// info about the directory that is pointed by the iterator
|
||||
|
||||
std::string name() const ;
|
||||
time_t last_modif_time() const ; // last time a file in this directory or in the directories below has been modified.
|
||||
time_t last_update_time() const ; // last time this directory was updated
|
||||
rstime_t last_modif_time() const ; // last time a file in this directory or in the directories below has been modified.
|
||||
rstime_t last_update_time() const ; // last time this directory was updated
|
||||
private:
|
||||
EntryIndex mParentIndex ; // index of the parent dir.
|
||||
uint32_t mDirTabIndex ; // index in the vector of subdirs.
|
||||
|
@ -106,7 +107,7 @@ class DirectoryStorage
|
|||
std::string name() const ;
|
||||
uint64_t size() const ;
|
||||
RsFileHash hash() const ;
|
||||
time_t modtime() const ;
|
||||
rstime_t modtime() const ;
|
||||
|
||||
private:
|
||||
EntryIndex mParentIndex ; // index of the parent dir.
|
||||
|
@ -117,7 +118,7 @@ class DirectoryStorage
|
|||
struct FileTS
|
||||
{
|
||||
uint64_t size ;
|
||||
time_t modtime;
|
||||
rstime_t modtime;
|
||||
};
|
||||
|
||||
EntryIndex root() const ; // returns the index of the root directory entry. This is generally 0.
|
||||
|
@ -171,7 +172,7 @@ class DirectoryStorage
|
|||
|
||||
InternalFileHierarchyStorage *mFileHierarchy ;
|
||||
|
||||
time_t mLastSavedTime ;
|
||||
rstime_t mLastSavedTime ;
|
||||
bool mChanged ;
|
||||
std::string mFileName;
|
||||
};
|
||||
|
@ -198,7 +199,7 @@ public:
|
|||
* returns the last time a sweep has been done over the directory in order to check update TS.
|
||||
* \return
|
||||
*/
|
||||
time_t& lastSweepTime() { return mLastSweepTime ; }
|
||||
rstime_t& lastSweepTime() { return mLastSweepTime ; }
|
||||
|
||||
/*!
|
||||
* \brief searchHash
|
||||
|
@ -212,7 +213,7 @@ public:
|
|||
virtual int searchHash(const RsFileHash& hash, EntryIndex& results) const ;
|
||||
|
||||
private:
|
||||
time_t mLastSweepTime ;
|
||||
rstime_t mLastSweepTime ;
|
||||
};
|
||||
|
||||
class LocalDirectoryStorage: public DirectoryStorage
|
||||
|
|
|
@ -64,7 +64,7 @@ void LocalDirectoryUpdater::setEnabled(bool b)
|
|||
|
||||
void LocalDirectoryUpdater::data_tick()
|
||||
{
|
||||
time_t now = time(NULL) ;
|
||||
rstime_t now = time(NULL) ;
|
||||
|
||||
if (mIsEnabled || mForceUpdate)
|
||||
{
|
||||
|
@ -190,14 +190,14 @@ void LocalDirectoryUpdater::recursUpdateSharedDir(const std::string& cumulated_p
|
|||
|
||||
librs::util::FolderIterator dirIt(cumulated_path,mFollowSymLinks,false); // disallow symbolic links and files from the future.
|
||||
|
||||
time_t dir_local_mod_time ;
|
||||
rstime_t dir_local_mod_time ;
|
||||
if(!mSharedDirectories->getDirectoryLocalModTime(indx,dir_local_mod_time))
|
||||
{
|
||||
std::cerr << "(EE) Cannot get local mod time for dir index " << indx << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
time_t now = time(NULL) ;
|
||||
rstime_t now = time(NULL) ;
|
||||
|
||||
if(mNeedsFullRecheck || dirIt.dir_modtime() > dir_local_mod_time) // the > is because we may have changed the virtual name, and therefore the TS wont match.
|
||||
// we only want to detect when the directory has changed on the disk
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
//
|
||||
#include "file_sharing/hash_cache.h"
|
||||
#include "file_sharing/directory_storage.h"
|
||||
#include "util/rstime.h"
|
||||
|
||||
class LocalDirectoryUpdater: public HashStorageClient, public RsTickingThread
|
||||
{
|
||||
|
@ -77,8 +78,8 @@ private:
|
|||
|
||||
RsFileHash mHashSalt ;
|
||||
|
||||
time_t mLastSweepTime;
|
||||
time_t mLastTSUpdateTime;
|
||||
rstime_t mLastSweepTime;
|
||||
rstime_t mLastTSUpdateTime;
|
||||
|
||||
uint32_t mDelayBetweenDirectoryUpdates;
|
||||
bool mIsEnabled ;
|
||||
|
|
|
@ -25,6 +25,7 @@ static const uint32_t DELAY_BETWEEN_DIRECTORY_UPDATES = 600 ; // 10 m
|
|||
static const uint32_t DELAY_BETWEEN_REMOTE_DIRECTORY_SYNC_REQ = 120 ; // 2 minutes
|
||||
static const uint32_t DELAY_BETWEEN_LOCAL_DIRECTORIES_TS_UPDATE = 20 ; // 20 sec. But we only update for real if something has changed.
|
||||
static const uint32_t DELAY_BETWEEN_REMOTE_DIRECTORIES_SWEEP = 60 ; // 60 sec.
|
||||
static const uint32_t DELAY_BETWEEN_EXTRA_FILES_CACHE_UPDATES = 2 ; // 2 sec.
|
||||
|
||||
static const uint32_t DELAY_BEFORE_DELETE_NON_EMPTY_REMOTE_DIR = 60*24*86400 ; // delete non empty remoe directories after 60 days of inactivity
|
||||
static const uint32_t DELAY_BEFORE_DELETE_EMPTY_REMOTE_DIR = 5*24*86400 ; // delete empty remote directories after 5 days of inactivity
|
||||
|
|
|
@ -232,7 +232,7 @@ void HashStorage::data_tick()
|
|||
job.client->hash_callback(job.client_param, job.full_path, hash, size);
|
||||
}
|
||||
|
||||
bool HashStorage::requestHash(const std::string& full_path,uint64_t size,time_t mod_time,RsFileHash& known_hash,HashStorageClient *c,uint32_t client_param)
|
||||
bool HashStorage::requestHash(const std::string& full_path,uint64_t size,rstime_t mod_time,RsFileHash& known_hash,HashStorageClient *c,uint32_t client_param)
|
||||
{
|
||||
// check if the hash is up to date w.r.t. cache.
|
||||
|
||||
|
@ -243,7 +243,7 @@ bool HashStorage::requestHash(const std::string& full_path,uint64_t size,time_t
|
|||
|
||||
std::string real_path = RsDirUtil::removeSymLinks(full_path) ;
|
||||
|
||||
time_t now = time(NULL) ;
|
||||
rstime_t now = time(NULL) ;
|
||||
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.
|
||||
|
@ -318,8 +318,8 @@ void HashStorage::clean()
|
|||
{
|
||||
RS_STACK_MUTEX(mHashMtx) ;
|
||||
|
||||
time_t now = time(NULL) ;
|
||||
time_t duration = mMaxStorageDurationDays * 24 * 3600 ; // seconds
|
||||
rstime_t now = time(NULL) ;
|
||||
rstime_t duration = mMaxStorageDurationDays * 24 * 3600 ; // seconds
|
||||
|
||||
#ifdef HASHSTORAGE_DEBUG
|
||||
std::cerr << "Cleaning hash cache." << std::endl ;
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include <map>
|
||||
#include "util/rsthreads.h"
|
||||
#include "retroshare/rsfiles.h"
|
||||
#include "util/rstime.h"
|
||||
|
||||
/*!
|
||||
* \brief The HashStorageClient class
|
||||
|
@ -65,7 +66,7 @@ public:
|
|||
*
|
||||
* \return true if the supplied hash info is up to date.
|
||||
*/
|
||||
bool requestHash(const std::string& full_path, uint64_t size, time_t mod_time, RsFileHash& known_hash, HashStorageClient *c, uint32_t client_param) ;
|
||||
bool requestHash(const std::string& full_path, uint64_t size, rstime_t mod_time, RsFileHash& known_hash, HashStorageClient *c, uint32_t client_param) ;
|
||||
|
||||
struct HashStorageInfo
|
||||
{
|
||||
|
@ -120,7 +121,7 @@ private:
|
|||
uint64_t size ;
|
||||
HashStorageClient *client;
|
||||
uint32_t client_param ;
|
||||
time_t ts;
|
||||
rstime_t ts;
|
||||
};
|
||||
|
||||
// current work
|
||||
|
@ -136,7 +137,7 @@ private:
|
|||
uint64_t mTotalSizeToHash ;
|
||||
uint64_t mTotalHashedSize ;
|
||||
uint64_t mTotalFilesToHash ;
|
||||
time_t mLastSaveTime ;
|
||||
rstime_t mLastSaveTime ;
|
||||
|
||||
// The following is used to estimate hashing speed.
|
||||
|
||||
|
|
|
@ -37,7 +37,8 @@
|
|||
#define P3FILELISTS_ERROR() std::cerr << "***ERROR***" << " : FILE_LISTS : " << __FUNCTION__ << " : "
|
||||
|
||||
//#define DEBUG_P3FILELISTS 1
|
||||
#define DEBUG_CONTENT_FILTERING 1
|
||||
//#define DEBUG_CONTENT_FILTERING 1
|
||||
//#define DEBUG_FILE_HIERARCHY 1
|
||||
|
||||
static const uint32_t P3FILELISTS_UPDATE_FLAG_NOTHING_CHANGED = 0x0000 ;
|
||||
static const uint32_t P3FILELISTS_UPDATE_FLAG_REMOTE_MAP_CHANGED = 0x0001 ;
|
||||
|
@ -71,6 +72,7 @@ p3FileDatabase::p3FileDatabase(p3ServiceControl *mpeers)
|
|||
|
||||
mUpdateFlags = P3FILELISTS_UPDATE_FLAG_NOTHING_CHANGED ;
|
||||
mLastRemoteDirSweepTS = 0 ;
|
||||
mLastExtraFilesCacheUpdate = 0;
|
||||
mLastCleanupTime = 0 ;
|
||||
mLastDataRecvTS = 0 ;
|
||||
mTrustFriendNodesForBannedFiles = TRUST_FRIEND_NODES_FOR_BANNED_FILES_DEFAULT;
|
||||
|
@ -169,7 +171,7 @@ int p3FileDatabase::tick()
|
|||
tickRecv() ;
|
||||
tickSend() ;
|
||||
|
||||
time_t now = time(NULL) ;
|
||||
rstime_t now = time(NULL) ;
|
||||
|
||||
// cleanup
|
||||
// - remove/delete shared file lists for people who are not friend anymore
|
||||
|
@ -181,7 +183,7 @@ int p3FileDatabase::tick()
|
|||
mLastCleanupTime = now ;
|
||||
}
|
||||
|
||||
static time_t last_print_time = 0;
|
||||
static rstime_t last_print_time = 0;
|
||||
|
||||
if(last_print_time + 20 < now)
|
||||
{
|
||||
|
@ -602,15 +604,15 @@ void p3FileDatabase::cleanup()
|
|||
for(std::list<RsPeerId>::const_iterator it(friend_lst.begin());it!=friend_lst.end();++it)
|
||||
friend_set.insert(*it) ;
|
||||
}
|
||||
time_t now = time(NULL);
|
||||
rstime_t now = time(NULL);
|
||||
|
||||
for(uint32_t i=0;i<mRemoteDirectories.size();++i)
|
||||
if(mRemoteDirectories[i] != NULL)
|
||||
{
|
||||
time_t recurs_mod_time ;
|
||||
rstime_t recurs_mod_time ;
|
||||
mRemoteDirectories[i]->getDirectoryRecursModTime(0,recurs_mod_time) ;
|
||||
|
||||
time_t last_contact = 0 ;
|
||||
rstime_t last_contact = 0 ;
|
||||
RsPeerDetails pd ;
|
||||
if(rsPeers->getPeerDetails(mRemoteDirectories[i]->peerId(),pd))
|
||||
last_contact = pd.lastConnect ;
|
||||
|
@ -892,6 +894,8 @@ void p3FileDatabase::requestDirUpdate(void *ref)
|
|||
}
|
||||
}
|
||||
|
||||
// Finds the pointer to the sub-element #row under element ref.
|
||||
|
||||
bool p3FileDatabase::findChildPointer( void *ref, int row, void *& result,
|
||||
FileSearchFlags flags ) const
|
||||
{
|
||||
|
@ -899,10 +903,10 @@ bool p3FileDatabase::findChildPointer( void *ref, int row, void *& result,
|
|||
{
|
||||
if(flags & RS_FILE_HINTS_LOCAL)
|
||||
{
|
||||
if(row != 0)
|
||||
if(row != 0 && row != 1)
|
||||
return false ;
|
||||
|
||||
convertEntryIndexToPointer<sizeof(void*)>(0,0,result);
|
||||
convertEntryIndexToPointer<sizeof(void*)>(0,row,result);
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
@ -921,12 +925,18 @@ bool p3FileDatabase::findChildPointer( void *ref, int row, void *& result,
|
|||
convertPointerToEntryIndex<sizeof(void*)>(ref,e,fi);
|
||||
|
||||
// check consistency
|
||||
if( (fi == 0 && !(flags & RS_FILE_HINTS_LOCAL)) || (fi > 0 && (flags & RS_FILE_HINTS_LOCAL)))
|
||||
if( (fi == 0 && !(flags & RS_FILE_HINTS_LOCAL)) || (fi > 1 && (flags & RS_FILE_HINTS_LOCAL)))
|
||||
{
|
||||
P3FILELISTS_ERROR() << "(EE) remote request on local index or local request on remote index. This should not happen." << std::endl;
|
||||
return false ;
|
||||
}
|
||||
DirectoryStorage *storage = (fi==0)? ((DirectoryStorage*)mLocalSharedDirs) : ((DirectoryStorage*)mRemoteDirectories[fi-1]);
|
||||
|
||||
if(fi==1 && (flags & RS_FILE_HINTS_LOCAL)) // extra list
|
||||
{
|
||||
convertEntryIndexToPointer<sizeof(void*)>(row+1,1,result);
|
||||
return true;
|
||||
}
|
||||
DirectoryStorage *storage = (flags & RS_FILE_HINTS_LOCAL)? ((DirectoryStorage*)mLocalSharedDirs) : ((DirectoryStorage*)mRemoteDirectories[fi-1]);
|
||||
|
||||
// Case where the index is the top of a single person. Can be us, or a friend.
|
||||
|
||||
|
@ -958,6 +968,78 @@ int p3FileDatabase::getSharedDirStatistics(const RsPeerId& pid,SharedDirStats& s
|
|||
}
|
||||
}
|
||||
|
||||
void p3FileDatabase::removeExtraFile(const RsFileHash& hash)
|
||||
{
|
||||
{
|
||||
RS_STACK_MUTEX(mFLSMtx) ;
|
||||
|
||||
mExtraFiles->removeExtraFile(hash);
|
||||
mLastExtraFilesCacheUpdate = 0 ; // forced cache reload
|
||||
}
|
||||
|
||||
RsServer::notify()->notifyListChange(NOTIFY_LIST_DIRLIST_LOCAL, 0);
|
||||
}
|
||||
|
||||
void p3FileDatabase::getExtraFilesDirDetails(void *ref,DirectoryStorage::EntryIndex e,DirDetails& d) const
|
||||
{
|
||||
// update the cache of extra files if last requested too long ago
|
||||
|
||||
rstime_t now = time(NULL);
|
||||
|
||||
if(mLastExtraFilesCacheUpdate + DELAY_BETWEEN_EXTRA_FILES_CACHE_UPDATES <= now)
|
||||
{
|
||||
mExtraFiles->getExtraFileList(mExtraFilesCache);
|
||||
mLastExtraFilesCacheUpdate = now;
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
if(e == 0) // "virtual extra files directory" => create a dir with as many child as they are extra files
|
||||
{
|
||||
d.parent = NULL ;
|
||||
|
||||
d.prow = 0;//fi-1 ;
|
||||
d.type = DIR_TYPE_PERSON;
|
||||
d.hash.clear() ;
|
||||
d.count = mExtraFilesCache.size();
|
||||
d.max_mtime = time(NULL);
|
||||
d.mtime = time(NULL);
|
||||
d.name = "[Extra List]";
|
||||
d.path = "/";
|
||||
d.ref = ref ;
|
||||
|
||||
for(uint32_t i=0;i<mExtraFilesCache.size();++i)
|
||||
{
|
||||
DirStub stub;
|
||||
stub.type = DIR_TYPE_FILE;
|
||||
stub.name = mExtraFilesCache[i].fname;
|
||||
convertEntryIndexToPointer<sizeof(void*)>(i+1,1,stub.ref); // local shared files from extra list
|
||||
|
||||
d.children.push_back(stub);
|
||||
}
|
||||
}
|
||||
else // extra file. Just query the corresponding data from ftExtra
|
||||
{
|
||||
d.prow = 1;//fi-1 ;
|
||||
d.type = DIR_TYPE_EXTRA_FILE;
|
||||
|
||||
FileInfo& f(mExtraFilesCache[(int)e-1]) ;
|
||||
|
||||
d.hash = f.hash;
|
||||
d.count = f.size;
|
||||
d.max_mtime = 0; // this is irrelevant
|
||||
d.mtime = 0; // this is irrelevant
|
||||
d.name = f.path; // so that the UI shows the complete path, since the parent directory is not really a directory.
|
||||
d.path = f.path;
|
||||
d.ref = ref ;
|
||||
|
||||
convertEntryIndexToPointer<sizeof(void*)>(0,1,d.parent) ;
|
||||
}
|
||||
|
||||
d.flags = DIR_FLAGS_ANONYMOUS_DOWNLOAD ;
|
||||
d.id = RsPeerId();
|
||||
}
|
||||
|
||||
// This function converts a pointer into directory details, to be used by the AbstractItemModel for browsing the files.
|
||||
int p3FileDatabase::RequestDirDetails(void *ref, DirDetails& d, FileSearchFlags flags) const
|
||||
{
|
||||
|
@ -983,10 +1065,8 @@ int p3FileDatabase::RequestDirDetails(void *ref, DirDetails& d, FileSearchFlags
|
|||
{
|
||||
d.ref = NULL ;
|
||||
d.type = DIR_TYPE_ROOT;
|
||||
d.count = 1;
|
||||
d.parent = NULL;
|
||||
d.prow = -1;
|
||||
d.ref = NULL;
|
||||
d.name = "root";
|
||||
d.hash.clear() ;
|
||||
d.path = "";
|
||||
|
@ -997,13 +1077,28 @@ int p3FileDatabase::RequestDirDetails(void *ref, DirDetails& d, FileSearchFlags
|
|||
if(flags & RS_FILE_HINTS_LOCAL)
|
||||
{
|
||||
void *p;
|
||||
convertEntryIndexToPointer<sizeof(void*)>(0,0,p);
|
||||
|
||||
{
|
||||
convertEntryIndexToPointer<sizeof(void*)>(0,0,p); // root of own directories
|
||||
DirStub stub;
|
||||
stub.type = DIR_TYPE_PERSON;
|
||||
stub.name = mServCtrl->getOwnId().toStdString();
|
||||
stub.ref = p;
|
||||
d.children.push_back(stub);
|
||||
}
|
||||
|
||||
if(mExtraFiles->size() > 0)
|
||||
{
|
||||
convertEntryIndexToPointer<sizeof(void*)>(0,1,p); // local shared files from extra list
|
||||
DirStub stub;
|
||||
stub.type = DIR_TYPE_PERSON; // not totally exact, but used as a trick.
|
||||
stub.name = "[Extra List]";
|
||||
stub.ref = p;
|
||||
|
||||
d.children.push_back(stub);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
else for(uint32_t i=0;i<mRemoteDirectories.size();++i)
|
||||
if(mRemoteDirectories[i] != NULL)
|
||||
|
@ -1022,6 +1117,7 @@ int p3FileDatabase::RequestDirDetails(void *ref, DirDetails& d, FileSearchFlags
|
|||
|
||||
#ifdef DEBUG_FILE_HIERARCHY
|
||||
P3FILELISTS_DEBUG() << "ExtractData: ref=" << ref << ", flags=" << flags << " : returning this: " << std::endl;
|
||||
P3FILELISTS_DEBUG() << d << std::endl;
|
||||
#endif
|
||||
|
||||
return true ;
|
||||
|
@ -1033,12 +1129,25 @@ int p3FileDatabase::RequestDirDetails(void *ref, DirDetails& d, FileSearchFlags
|
|||
convertPointerToEntryIndex<sizeof(void*)>(ref,e,fi);
|
||||
|
||||
// check consistency
|
||||
if( (fi == 0 && !(flags & RS_FILE_HINTS_LOCAL)) || (fi > 0 && (flags & RS_FILE_HINTS_LOCAL)))
|
||||
if( (fi == 0 && !(flags & RS_FILE_HINTS_LOCAL)) || (fi > 1 && (flags & RS_FILE_HINTS_LOCAL)))
|
||||
{
|
||||
P3FILELISTS_ERROR() << "(EE) remote request on local index or local request on remote index. This should not happen." << std::endl;
|
||||
return false ;
|
||||
}
|
||||
DirectoryStorage *storage = (fi==0)? ((DirectoryStorage*)mLocalSharedDirs) : ((DirectoryStorage*)mRemoteDirectories[fi-1]);
|
||||
|
||||
if((flags & RS_FILE_HINTS_LOCAL) && fi == 1) // extra list
|
||||
{
|
||||
getExtraFilesDirDetails(ref,e,d);
|
||||
|
||||
#ifdef DEBUG_FILE_HIERARCHY
|
||||
P3FILELISTS_DEBUG() << "ExtractData: ref=" << ref << ", flags=" << flags << " : returning this: " << std::endl;
|
||||
P3FILELISTS_DEBUG() << d << std::endl;
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
DirectoryStorage *storage = (flags & RS_FILE_HINTS_LOCAL)? ((DirectoryStorage*)mLocalSharedDirs) : ((DirectoryStorage*)mRemoteDirectories[fi-1]);
|
||||
|
||||
// Case where the index is the top of a single person. Can be us, or a friend.
|
||||
|
||||
|
@ -1083,7 +1192,7 @@ int p3FileDatabase::RequestDirDetails(void *ref, DirDetails& d, FileSearchFlags
|
|||
return true;
|
||||
}
|
||||
|
||||
uint32_t p3FileDatabase::getType(void *ref) const
|
||||
uint32_t p3FileDatabase::getType(void *ref,FileSearchFlags flags) const
|
||||
{
|
||||
RS_STACK_MUTEX(mFLSMtx) ;
|
||||
|
||||
|
@ -1098,12 +1207,25 @@ uint32_t p3FileDatabase::getType(void *ref) const
|
|||
if(e == 0)
|
||||
return DIR_TYPE_PERSON ;
|
||||
|
||||
if(fi == 0 && mLocalSharedDirs != NULL)
|
||||
return mLocalSharedDirs->getEntryType(e) ;
|
||||
else if(fi-1 < mRemoteDirectories.size() && mRemoteDirectories[fi-1]!=NULL)
|
||||
return mRemoteDirectories[fi-1]->getEntryType(e) ;
|
||||
else
|
||||
if(flags & RS_FILE_HINTS_LOCAL)
|
||||
{
|
||||
if(fi == 0 && mLocalSharedDirs != NULL)
|
||||
return mLocalSharedDirs->getEntryType(e) ;
|
||||
|
||||
if(fi == 1)
|
||||
return DIR_TYPE_EXTRA_FILE;
|
||||
|
||||
P3FILELISTS_ERROR() << " Cannot determine type of entry " << ref << std::endl;
|
||||
return DIR_TYPE_ROOT ;// some failure case. Should not happen
|
||||
}
|
||||
else
|
||||
{
|
||||
if(fi-1 < mRemoteDirectories.size() && mRemoteDirectories[fi-1]!=NULL)
|
||||
return mRemoteDirectories[fi-1]->getEntryType(e) ;
|
||||
|
||||
P3FILELISTS_ERROR() << " Cannot determine type of entry " << ref << std::endl;
|
||||
return DIR_TYPE_ROOT ;// some failure case. Should not happen
|
||||
}
|
||||
}
|
||||
|
||||
void p3FileDatabase::forceDirectoryCheck() // Force re-sweep the directories and see what's changed
|
||||
|
@ -1503,7 +1625,7 @@ void p3FileDatabase::handleDirSyncRequest(RsFileListsSyncRequestItem *item)
|
|||
}
|
||||
else
|
||||
{
|
||||
time_t local_recurs_max_time ;
|
||||
rstime_t local_recurs_max_time ;
|
||||
mLocalSharedDirs->getDirectoryRecursModTime(entry_index,local_recurs_max_time) ;
|
||||
|
||||
if(item->last_known_recurs_modf_TS != local_recurs_max_time) // normally, should be "<", but since we provided the TS it should be equal, so != is more robust.
|
||||
|
@ -1668,7 +1790,7 @@ void p3FileDatabase::handleDirSyncResponse(RsFileListsSyncResponseItem*& sitem)
|
|||
sitem = item ;
|
||||
}
|
||||
|
||||
time_t now = time(NULL);
|
||||
rstime_t now = time(NULL);
|
||||
|
||||
// check the hash. If anything goes wrong (in the chunking for instance) the hash will not match
|
||||
|
||||
|
@ -1775,7 +1897,7 @@ void p3FileDatabase::handleDirSyncResponse(RsFileListsSyncResponseItem*& sitem)
|
|||
|
||||
void p3FileDatabase::locked_recursSweepRemoteDirectory(RemoteDirectoryStorage *rds,DirectoryStorage::EntryIndex e,int depth)
|
||||
{
|
||||
time_t now = time(NULL) ;
|
||||
rstime_t now = time(NULL) ;
|
||||
|
||||
//std::string indent(2*depth,' ') ;
|
||||
|
||||
|
@ -1788,7 +1910,7 @@ void p3FileDatabase::locked_recursSweepRemoteDirectory(RemoteDirectoryStorage *r
|
|||
P3FILELISTS_DEBUG() << "currently at entry index " << e << std::endl;
|
||||
#endif
|
||||
|
||||
time_t local_update_TS;
|
||||
rstime_t local_update_TS;
|
||||
|
||||
if(!rds->getDirectoryUpdateTime(e,local_update_TS))
|
||||
{
|
||||
|
@ -1835,9 +1957,9 @@ p3FileDatabase::DirSyncRequestId p3FileDatabase::makeDirSyncReqId(const RsPeerId
|
|||
bool p3FileDatabase::locked_generateAndSendSyncRequest(RemoteDirectoryStorage *rds,const DirectoryStorage::EntryIndex& e)
|
||||
{
|
||||
RsFileHash entry_hash ;
|
||||
time_t now = time(NULL) ;
|
||||
rstime_t now = time(NULL) ;
|
||||
|
||||
time_t max_known_recurs_modf_time ;
|
||||
rstime_t max_known_recurs_modf_time ;
|
||||
|
||||
if(!rds->getDirectoryRecursModTime(e,max_known_recurs_modf_time))
|
||||
{
|
||||
|
@ -1994,7 +2116,7 @@ void p3FileDatabase::checkSendBannedFilesInfo()
|
|||
P3FILELISTS_DEBUG() << " Checking banned files information: " << std::endl;
|
||||
#endif
|
||||
|
||||
time_t now = time(NULL);
|
||||
rstime_t now = time(NULL);
|
||||
std::list<RsPeerId> online_friends ;
|
||||
rsPeers->getOnlineList(online_friends);
|
||||
|
||||
|
|
|
@ -45,9 +45,10 @@
|
|||
#pragma once
|
||||
|
||||
#include "ft/ftsearch.h"
|
||||
#include "ft/ftextralist.h"
|
||||
#include "retroshare/rsfiles.h"
|
||||
#include "services/p3service.h"
|
||||
|
||||
#include "util/rstime.h"
|
||||
#include "file_sharing/hash_cache.h"
|
||||
#include "file_sharing/directory_storage.h"
|
||||
|
||||
|
@ -70,7 +71,7 @@ struct PeerBannedFilesEntry
|
|||
{
|
||||
std::set<RsFileHash> mBannedHashOfHash;
|
||||
uint32_t mSessionId ; // used for when a friend sends multiple packets in separate items.
|
||||
time_t mLastSent;
|
||||
rstime_t mLastSent;
|
||||
};
|
||||
|
||||
class p3FileDatabase: public p3Service, public p3Config, public ftSearch //, public RsSharedFileService
|
||||
|
@ -87,9 +88,10 @@ class p3FileDatabase: public p3Service, public p3Config, public ftSearch //, pub
|
|||
// [...] more to add here
|
||||
};
|
||||
|
||||
explicit p3FileDatabase(p3ServiceControl *mpeers) ;
|
||||
explicit p3FileDatabase(p3ServiceControl *mpeers);
|
||||
~p3FileDatabase();
|
||||
|
||||
void setExtraList(ftExtraList *f) { mExtraFiles = f ; }
|
||||
/*!
|
||||
* \brief forceSyncWithPeers
|
||||
*
|
||||
|
@ -107,6 +109,9 @@ class p3FileDatabase: public p3Service, public p3Config, public ftSearch //, pub
|
|||
virtual int SearchKeywords(const std::list<std::string>& keywords, std::list<DirDetails>& results,FileSearchFlags flags,const RsPeerId& peer_id) ;
|
||||
virtual int SearchBoolExp(RsRegularExpression::Expression *exp, std::list<DirDetails>& results,FileSearchFlags flags,const RsPeerId& peer_id) const ;
|
||||
|
||||
// Extra file list
|
||||
virtual void removeExtraFile(const RsFileHash& hash);
|
||||
|
||||
// Interface for browsing dir hierarchy
|
||||
//
|
||||
|
||||
|
@ -119,7 +124,7 @@ class p3FileDatabase: public p3Service, public p3Config, public ftSearch //, pub
|
|||
|
||||
void requestDirUpdate(void *ref) ; // triggers an update. Used when browsing.
|
||||
int RequestDirDetails(void *, DirDetails&, FileSearchFlags) const ;
|
||||
uint32_t getType(void *) const ;
|
||||
uint32_t getType(void *, FileSearchFlags flags) const ;
|
||||
|
||||
// proxy method used by the web UI. Dont't delete!
|
||||
int RequestDirDetails(const RsPeerId& uid, const std::string& path, DirDetails &details)const;
|
||||
|
@ -169,6 +174,7 @@ class p3FileDatabase: public p3Service, public p3Config, public ftSearch //, pub
|
|||
bool hashingProcessPaused();
|
||||
|
||||
protected:
|
||||
void getExtraFilesDirDetails(void *ref,DirectoryStorage::EntryIndex e,DirDetails& d) const;
|
||||
|
||||
int filterResults(const std::list<void*>& firesults,std::list<DirDetails>& results,FileSearchFlags flags,const RsPeerId& peer_id) const;
|
||||
std::string makeRemoteFileName(const RsPeerId& pid) const;
|
||||
|
@ -219,8 +225,8 @@ class p3FileDatabase: public p3Service, public p3Config, public ftSearch //, pub
|
|||
|
||||
std::vector<RemoteDirectoryStorage *> mRemoteDirectories ;
|
||||
LocalDirectoryStorage *mLocalSharedDirs ;
|
||||
|
||||
LocalDirectoryUpdater *mLocalDirWatcher ;
|
||||
ftExtraList *mExtraFiles;
|
||||
|
||||
// utility functions to make/get a pointer out of an (EntryIndex,PeerId) pair. This is further documented in the .cc
|
||||
|
||||
|
@ -240,11 +246,11 @@ class p3FileDatabase: public p3Service, public p3Config, public ftSearch //, pub
|
|||
struct DirSyncRequestData
|
||||
{
|
||||
RsPeerId peer_id ;
|
||||
time_t request_TS ;
|
||||
rstime_t request_TS ;
|
||||
uint32_t flags ;
|
||||
};
|
||||
|
||||
time_t mLastRemoteDirSweepTS ; // TS for friend list update
|
||||
rstime_t mLastRemoteDirSweepTS ; // TS for friend list update
|
||||
std::map<DirSyncRequestId,DirSyncRequestData> mPendingSyncRequests ; // pending requests, waiting for an answer
|
||||
std::map<DirSyncRequestId,RsFileListsSyncResponseItem *> mPartialResponseItems;
|
||||
|
||||
|
@ -259,8 +265,8 @@ class p3FileDatabase: public p3Service, public p3Config, public ftSearch //, pub
|
|||
mutable RsMutex mFLSMtx ;
|
||||
uint32_t mUpdateFlags ;
|
||||
std::string mFileSharingDir ;
|
||||
time_t mLastCleanupTime;
|
||||
time_t mLastDataRecvTS ;
|
||||
rstime_t mLastCleanupTime;
|
||||
rstime_t mLastDataRecvTS ;
|
||||
|
||||
// File filtering. Not explicitly related to shared files, but has its place here
|
||||
//
|
||||
|
@ -268,9 +274,11 @@ class p3FileDatabase: public p3Service, public p3Config, public ftSearch //, pub
|
|||
std::map<RsFileHash,BannedFileEntry> mPrimaryBanList ; // primary list (user controlled) of files banned from FT search and forwarding. map<real hash, BannedFileEntry>
|
||||
std::map<RsPeerId,PeerBannedFilesEntry> mPeerBannedFiles ; // records of which files other peers ban, stored as H(H(f))
|
||||
std::set<RsFileHash> mBannedFileList ; // list of banned hashes. This include original hashs and H(H(f)) when coming from friends.
|
||||
mutable std::vector<FileInfo> mExtraFilesCache; // cache for extra files, to avoid requesting them too often.
|
||||
mutable rstime_t mLastExtraFilesCacheUpdate ;
|
||||
bool mTrustFriendNodesForBannedFiles ;
|
||||
bool mBannedFileListNeedsUpdate;
|
||||
time_t mLastPrimaryBanListChangeTimeStamp;
|
||||
rstime_t mLastPrimaryBanListChangeTimeStamp;
|
||||
|
||||
void locked_sendBanInfo(const RsPeerId& pid);
|
||||
void handleBannedFilesInfo(RsFileListsBannedHashesItem *item);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue