mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
fixed virtual names
This commit is contained in:
parent
43f4f5d2d9
commit
2d1824b01d
@ -1,5 +1,6 @@
|
|||||||
#include <set>
|
#include <set>
|
||||||
#include "util/rsdir.h"
|
#include "util/rsdir.h"
|
||||||
|
#include "util/rsstring.h"
|
||||||
#include "directory_storage.h"
|
#include "directory_storage.h"
|
||||||
|
|
||||||
/******************************************************************************************************************/
|
/******************************************************************************************************************/
|
||||||
@ -374,6 +375,7 @@ time_t DirectoryStorage::FileIterator::modtime() const { const InternalFil
|
|||||||
DirectoryStorage::DirectoryStorage(const std::string& local_file_name)
|
DirectoryStorage::DirectoryStorage(const std::string& local_file_name)
|
||||||
: mFileName(local_file_name), mDirStorageMtx("Directory storage "+local_file_name)
|
: mFileName(local_file_name), mDirStorageMtx("Directory storage "+local_file_name)
|
||||||
{
|
{
|
||||||
|
RS_STACK_MUTEX(mDirStorageMtx) ;
|
||||||
mFileHierarchy = new InternalFileHierarchyStorage();
|
mFileHierarchy = new InternalFileHierarchyStorage();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -446,8 +448,33 @@ void LocalDirectoryStorage::setSharedDirectoryList(const std::list<SharedDirInfo
|
|||||||
{
|
{
|
||||||
RS_STACK_MUTEX(mDirStorageMtx) ;
|
RS_STACK_MUTEX(mDirStorageMtx) ;
|
||||||
|
|
||||||
|
// Chose virtual name if not supplied, and remove duplicates.
|
||||||
|
|
||||||
|
std::set<std::string> virtual_names ; // maps virtual to real name
|
||||||
|
std::list<SharedDirInfo> processed_list ;
|
||||||
|
|
||||||
for(std::list<SharedDirInfo>::const_iterator it(lst.begin());it!= lst.end();++it)
|
for(std::list<SharedDirInfo>::const_iterator it(lst.begin());it!= lst.end();++it)
|
||||||
mLocalDirs[(*it).filename] = *it ;
|
{
|
||||||
|
int i=0;
|
||||||
|
std::string candidate_virtual_name = it->virtualname ;
|
||||||
|
|
||||||
|
if(candidate_virtual_name.empty())
|
||||||
|
candidate_virtual_name = RsDirUtil::getTopDir(it->filename);
|
||||||
|
|
||||||
|
while(virtual_names.find(candidate_virtual_name) != virtual_names.end())
|
||||||
|
rs_sprintf_append(candidate_virtual_name, "-%d", ++i);
|
||||||
|
|
||||||
|
SharedDirInfo d(*it);
|
||||||
|
d.virtualname = candidate_virtual_name ;
|
||||||
|
processed_list.push_back(d) ;
|
||||||
|
|
||||||
|
virtual_names.insert(candidate_virtual_name) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
mLocalDirs.clear();
|
||||||
|
|
||||||
|
for(std::list<SharedDirInfo>::const_iterator it(processed_list.begin());it!=processed_list.end();++it)
|
||||||
|
mLocalDirs[it->filename] = *it;
|
||||||
}
|
}
|
||||||
void LocalDirectoryStorage::getSharedDirectoryList(std::list<SharedDirInfo>& lst)
|
void LocalDirectoryStorage::getSharedDirectoryList(std::list<SharedDirInfo>& lst)
|
||||||
{
|
{
|
||||||
@ -509,6 +536,7 @@ std::string LocalDirectoryStorage::locked_findRealRootFromVirtualFilename(const
|
|||||||
|
|
||||||
bool LocalDirectoryStorage::getFileInfo(DirectoryStorage::EntryIndex i,FileInfo& info)
|
bool LocalDirectoryStorage::getFileInfo(DirectoryStorage::EntryIndex i,FileInfo& info)
|
||||||
{
|
{
|
||||||
|
RS_STACK_MUTEX(mDirStorageMtx) ;
|
||||||
NOT_IMPLEMENTED() ;
|
NOT_IMPLEMENTED() ;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#include "util/folderiterator.h"
|
#include "util/folderiterator.h"
|
||||||
|
#include "rsserver/p3face.h"
|
||||||
|
|
||||||
#include "directory_storage.h"
|
#include "directory_storage.h"
|
||||||
#include "directory_updater.h"
|
#include "directory_updater.h"
|
||||||
@ -31,8 +32,15 @@ void LocalDirectoryUpdater::data_tick()
|
|||||||
usleep(10*1000*1000);
|
usleep(10*1000*1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LocalDirectoryUpdater::forceUpdate()
|
||||||
|
{
|
||||||
|
mLastSweepTime = 0;
|
||||||
|
}
|
||||||
|
|
||||||
void LocalDirectoryUpdater::sweepSharedDirectories()
|
void LocalDirectoryUpdater::sweepSharedDirectories()
|
||||||
{
|
{
|
||||||
|
RsServer::notify()->notifyListPreChange(NOTIFY_LIST_DIRLIST_LOCAL, 0);
|
||||||
|
|
||||||
std::cerr << "LocalDirectoryUpdater::sweep()" << std::endl;
|
std::cerr << "LocalDirectoryUpdater::sweep()" << std::endl;
|
||||||
|
|
||||||
// recursive update algorithm works that way:
|
// recursive update algorithm works that way:
|
||||||
@ -62,6 +70,7 @@ void LocalDirectoryUpdater::sweepSharedDirectories()
|
|||||||
std::cerr << " recursing into " << real_dir_it->filename << std::endl;
|
std::cerr << " recursing into " << real_dir_it->filename << std::endl;
|
||||||
recursUpdateSharedDir(real_dir_it->filename, *stored_dir_it) ;
|
recursUpdateSharedDir(real_dir_it->filename, *stored_dir_it) ;
|
||||||
}
|
}
|
||||||
|
RsServer::notify()->notifyListChange(NOTIFY_LIST_DIRLIST_LOCAL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LocalDirectoryUpdater::recursUpdateSharedDir(const std::string& cumulated_path, DirectoryStorage::EntryIndex indx)
|
void LocalDirectoryUpdater::recursUpdateSharedDir(const std::string& cumulated_path, DirectoryStorage::EntryIndex indx)
|
||||||
|
@ -19,9 +19,11 @@ public:
|
|||||||
LocalDirectoryUpdater(HashStorage *hash_cache,LocalDirectoryStorage *lds) ;
|
LocalDirectoryUpdater(HashStorage *hash_cache,LocalDirectoryStorage *lds) ;
|
||||||
virtual ~LocalDirectoryUpdater() {}
|
virtual ~LocalDirectoryUpdater() {}
|
||||||
|
|
||||||
virtual void data_tick() ;
|
virtual void forceUpdate();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
virtual void data_tick() ;
|
||||||
|
|
||||||
virtual void hash_callback(uint32_t client_param, const std::string& name, const RsFileHash& hash, uint64_t size);
|
virtual void hash_callback(uint32_t client_param, const std::string& name, const RsFileHash& hash, uint64_t size);
|
||||||
void recursUpdateSharedDir(const std::string& cumulated_path,DirectoryStorage::EntryIndex indx);
|
void recursUpdateSharedDir(const std::string& cumulated_path,DirectoryStorage::EntryIndex indx);
|
||||||
void sweepSharedDirectories();
|
void sweepSharedDirectories();
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#include "util/rsdir.h"
|
#include "util/rsdir.h"
|
||||||
|
#include "rsserver/p3face.h"
|
||||||
#include "hash_cache.h"
|
#include "hash_cache.h"
|
||||||
|
|
||||||
#define HASHSTORAGE_DEBUG 1
|
#define HASHSTORAGE_DEBUG 1
|
||||||
@ -25,6 +26,8 @@ void HashStorage::data_tick()
|
|||||||
mRunning = false ;
|
mRunning = false ;
|
||||||
std::cerr << "done." << std::endl;
|
std::cerr << "done." << std::endl;
|
||||||
|
|
||||||
|
RsServer::notify()->notifyHashingInfo(NOTIFY_HASHTYPE_FINISH, "") ;
|
||||||
|
|
||||||
usleep(2*1000*1000); // when no files to hash, just wait for 2 secs. This avoids a dramatic loop.
|
usleep(2*1000*1000); // when no files to hash, just wait for 2 secs. This avoids a dramatic loop.
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
@ -33,6 +36,10 @@ void HashStorage::data_tick()
|
|||||||
|
|
||||||
std::cerr << "Hashing file " << job.full_path << "..." ; std::cerr.flush();
|
std::cerr << "Hashing file " << job.full_path << "..." ; std::cerr.flush();
|
||||||
|
|
||||||
|
std::string tmpout;
|
||||||
|
//rs_sprintf(tmpout, "%lu/%lu (%s - %d%%) : %s", cnt+1, n_files, friendlyUnit(size).c_str(), int(size/double(total_size)*100.0), fe.name.c_str()) ;
|
||||||
|
|
||||||
|
RsServer::notify()->notifyHashingInfo(NOTIFY_HASHTYPE_HASH_FILE, job.full_path) ;
|
||||||
|
|
||||||
if(!RsDirUtil::getFileHash(job.full_path, hash,size, this))
|
if(!RsDirUtil::getFileHash(job.full_path, hash,size, this))
|
||||||
std::cerr << "ERROR: cannot hash file " << job.full_path << std::endl;
|
std::cerr << "ERROR: cannot hash file " << job.full_path << std::endl;
|
||||||
|
@ -7,6 +7,8 @@
|
|||||||
#include "retroshare/rsids.h"
|
#include "retroshare/rsids.h"
|
||||||
#include "retroshare/rspeers.h"
|
#include "retroshare/rspeers.h"
|
||||||
|
|
||||||
|
#include "rsserver/p3face.h"
|
||||||
|
|
||||||
#define P3FILELISTS_DEBUG() std::cerr << "p3FileLists: "
|
#define P3FILELISTS_DEBUG() std::cerr << "p3FileLists: "
|
||||||
|
|
||||||
static const uint32_t P3FILELISTS_UPDATE_FLAG_NOTHING_CHANGED = 0x0000 ;
|
static const uint32_t P3FILELISTS_UPDATE_FLAG_NOTHING_CHANGED = 0x0000 ;
|
||||||
@ -36,14 +38,19 @@ p3FileDatabase::p3FileDatabase(p3ServiceControl *mpeers)
|
|||||||
|
|
||||||
void p3FileDatabase::setSharedDirectories(const std::list<SharedDirInfo>& shared_dirs)
|
void p3FileDatabase::setSharedDirectories(const std::list<SharedDirInfo>& shared_dirs)
|
||||||
{
|
{
|
||||||
|
RS_STACK_MUTEX(mFLSMtx) ;
|
||||||
|
|
||||||
mLocalSharedDirs->setSharedDirectoryList(shared_dirs) ;
|
mLocalSharedDirs->setSharedDirectoryList(shared_dirs) ;
|
||||||
|
mLocalDirWatcher->forceUpdate();
|
||||||
}
|
}
|
||||||
void p3FileDatabase::getSharedDirectories(std::list<SharedDirInfo>& shared_dirs)
|
void p3FileDatabase::getSharedDirectories(std::list<SharedDirInfo>& shared_dirs)
|
||||||
{
|
{
|
||||||
|
RS_STACK_MUTEX(mFLSMtx) ;
|
||||||
mLocalSharedDirs->getSharedDirectoryList(shared_dirs) ;
|
mLocalSharedDirs->getSharedDirectoryList(shared_dirs) ;
|
||||||
}
|
}
|
||||||
void p3FileDatabase::updateShareFlags(const SharedDirInfo& info)
|
void p3FileDatabase::updateShareFlags(const SharedDirInfo& info)
|
||||||
{
|
{
|
||||||
|
RS_STACK_MUTEX(mFLSMtx) ;
|
||||||
mLocalSharedDirs->updateShareFlags(info) ;
|
mLocalSharedDirs->updateShareFlags(info) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user