mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-03 14:45:12 -04:00
Lots of bugfixes and tweaks:
* Switched p3Ranking to share Friends Links as well as own. * Modified rankmsgs to contain source id. * Fixed up rsNotify, added pqiNotify and global function call to get it. * Added notify for Bad Incoming Directory * Added Emergency Incoming directory so RS can keep running. * Added notify for Bad Packet (connecting to V0.3.X) * Added notify for Incomplete Packet Read (not been triggered yet!) * added close() to BinInterface, close on pqissl calls reset() * removed exit(1) calls from pqistreamer, replaced with bio->close(). * Increased Maximum Packet Size for HTML messages. * Fixed Online/Offline Message Forwarding. (TEST). * Increased DHT bootstrap buckets to 4. * Cleaned up much of serialiser debug (was slowing down Mac) * Added directory path to File Listings. * added ConvertSharedFilePath() so correct local dir can be found. * Added ForceDirectoryCheck() and InDirectoryCheck() for file hashing. * removed old TMP cache loading. * switched off Cache debug. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@448 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
a76baa5421
commit
5e41b21cef
36 changed files with 632 additions and 224 deletions
|
@ -30,9 +30,9 @@
|
|||
#include <sstream>
|
||||
#include <iomanip>
|
||||
|
||||
/***/
|
||||
/***
|
||||
#define CS_DEBUG 1
|
||||
/***/
|
||||
***/
|
||||
|
||||
bool operator<(const CacheId &a, const CacheId &b)
|
||||
{
|
||||
|
@ -529,6 +529,9 @@ void CacheStrapper::refreshCache(const CacheData &data)
|
|||
/* we've received an update
|
||||
* send to all online peers + self
|
||||
*/
|
||||
#ifdef CS_DEBUG
|
||||
std::cerr << "CacheStrapper::refreshCache() : " << data << std::endl;
|
||||
#endif
|
||||
|
||||
std::list<std::string> ids;
|
||||
std::list<std::string>::iterator it;
|
||||
|
@ -538,6 +541,10 @@ void CacheStrapper::refreshCache(const CacheData &data)
|
|||
RsStackMutex stack(csMtx); /******* LOCK STACK MUTEX *********/
|
||||
for(it = ids.begin(); it != ids.end(); it++)
|
||||
{
|
||||
#ifdef CS_DEBUG
|
||||
std::cerr << "CacheStrapper::refreshCache() Send To: " << *it << std::endl;
|
||||
#endif
|
||||
|
||||
mCacheUpdates.push_back(std::make_pair(*it, data));
|
||||
}
|
||||
|
||||
|
|
|
@ -40,7 +40,8 @@
|
|||
|
||||
FileIndexMonitor::FileIndexMonitor(CacheStrapper *cs, std::string cachedir, std::string pid)
|
||||
:CacheSource(RS_SERVICE_TYPE_FILE_INDEX, false, cs, cachedir), fi(pid),
|
||||
pendingDirs(false), pendingForceCacheWrite(false)
|
||||
pendingDirs(false), pendingForceCacheWrite(false),
|
||||
mForceCheck(false), mInCheck(false)
|
||||
|
||||
{
|
||||
updatePeriod = 60;
|
||||
|
@ -98,6 +99,32 @@ bool FileIndexMonitor::findLocalFile(std::string hash,
|
|||
return ok;
|
||||
}
|
||||
|
||||
bool FileIndexMonitor::convertSharedFilePath(std::string path, std::string &fullpath)
|
||||
{
|
||||
bool ok = false;
|
||||
|
||||
fiMutex.lock(); { /* LOCKED DIRS */
|
||||
|
||||
std::cerr << "FileIndexMonitor::convertSharedFilePath() path: " << path << std::endl;
|
||||
|
||||
std::string shpath = RsDirUtil::removeRootDir(path);
|
||||
std::string basedir = RsDirUtil::getRootDir(path);
|
||||
std::string realroot = findRealRoot(basedir);
|
||||
|
||||
/* construct full name */
|
||||
if (realroot.length() > 0)
|
||||
{
|
||||
fullpath = realroot + "/";
|
||||
fullpath += shpath;
|
||||
std::cerr << "FileIndexMonitor::convertSharedFilePath() Found Path: " << fullpath << std::endl;
|
||||
ok = true;
|
||||
}
|
||||
|
||||
} fiMutex.unlock(); /* UNLOCKED DIRS */
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
|
||||
bool FileIndexMonitor::loadLocalCache(const CacheData &data) /* called with stored data */
|
||||
{
|
||||
|
@ -180,6 +207,11 @@ void FileIndexMonitor::updateCycle()
|
|||
bool moretodo = true;
|
||||
bool fiMods = false;
|
||||
|
||||
{
|
||||
RsStackMutex stack(fiMutex); /**** LOCKED DIRS ****/
|
||||
mInCheck = true;
|
||||
}
|
||||
|
||||
while(moretodo)
|
||||
{
|
||||
/* sleep a bit for each loop */
|
||||
|
@ -527,6 +559,11 @@ void FileIndexMonitor::updateCycle()
|
|||
|
||||
} fiMutex.unlock(); /* UNLOCKED DIRS */
|
||||
}
|
||||
|
||||
{
|
||||
RsStackMutex stack(fiMutex); /**** LOCKED DIRS ****/
|
||||
mInCheck = false;
|
||||
}
|
||||
}
|
||||
|
||||
/* interface */
|
||||
|
@ -540,6 +577,27 @@ void FileIndexMonitor::setSharedDirectories(std::list<std::string> dirs)
|
|||
} fiMutex.unlock(); /* UNLOCKED DIRS */
|
||||
}
|
||||
|
||||
/* interface */
|
||||
void FileIndexMonitor::forceDirectoryCheck()
|
||||
{
|
||||
fiMutex.lock(); { /* LOCKED DIRS */
|
||||
|
||||
if (!mInCheck)
|
||||
mForceCheck = true;
|
||||
|
||||
} fiMutex.unlock(); /* UNLOCKED DIRS */
|
||||
}
|
||||
|
||||
|
||||
/* interface */
|
||||
bool FileIndexMonitor::inDirectoryCheck()
|
||||
{
|
||||
RsStackMutex stack(fiMutex); /**** LOCKED DIRS ****/
|
||||
|
||||
return mInCheck;
|
||||
}
|
||||
|
||||
|
||||
bool FileIndexMonitor::internal_setSharedDirectories()
|
||||
{
|
||||
int i;
|
||||
|
@ -547,10 +605,18 @@ bool FileIndexMonitor::internal_setSharedDirectories()
|
|||
|
||||
if (!pendingDirs)
|
||||
{
|
||||
if (mForceCheck)
|
||||
{
|
||||
mForceCheck = false;
|
||||
fiMutex.unlock(); /* UNLOCKED DIRS */
|
||||
return true;
|
||||
}
|
||||
|
||||
fiMutex.unlock(); /* UNLOCKED DIRS */
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
mForceCheck = false;
|
||||
pendingDirs = false;
|
||||
pendingForceCacheWrite = true;
|
||||
|
||||
|
|
|
@ -74,6 +74,9 @@ virtual ~FileIndexMonitor();
|
|||
/* external interface for filetransfer */
|
||||
bool findLocalFile(std::string hash, std::string &fullpath, uint64_t &size);
|
||||
|
||||
/* external interface for local access to files */
|
||||
bool convertSharedFilePath(std::string path, std::string &fullpath);
|
||||
|
||||
|
||||
/* Interacting with CacheSource */
|
||||
/* overloaded from CacheSource */
|
||||
|
@ -87,7 +90,8 @@ void updateCycle();
|
|||
|
||||
void setSharedDirectories(std::list<std::string> dirs);
|
||||
void setPeriod(int insecs);
|
||||
|
||||
void forceDirectoryCheck();
|
||||
bool inDirectoryCheck();
|
||||
/* util fns */
|
||||
|
||||
private:
|
||||
|
@ -109,6 +113,10 @@ bool hashFile(std::string path, FileEntry &fi); /* To Implement */
|
|||
bool pendingDirs;
|
||||
bool pendingForceCacheWrite;
|
||||
|
||||
/* flags to force Check, to tell if we're in check */
|
||||
bool mForceCheck;
|
||||
bool mInCheck;
|
||||
|
||||
std::list<std::string> pendingDirList;
|
||||
bool internal_setSharedDirectories();
|
||||
|
||||
|
|
|
@ -297,9 +297,6 @@ int FileIndexStore::RequestDirDetails(void *ref, DirDetails &details, uint32_t f
|
|||
details.age = time(NULL) - file->modtime;
|
||||
details.rank = file->pop;
|
||||
|
||||
/* TODO Path */
|
||||
details.path = "";
|
||||
|
||||
/* find parent pointer, and row */
|
||||
DirEntry *parent = file->parent;
|
||||
if (!parent) /* then must be root */
|
||||
|
@ -321,6 +318,9 @@ int FileIndexStore::RequestDirDetails(void *ref, DirDetails &details, uint32_t f
|
|||
parent=file->parent;
|
||||
}
|
||||
|
||||
/* NEW add path (to dir - if dir, or parent dir - if file? */
|
||||
details.path = parent->path;
|
||||
|
||||
while(parent->parent)
|
||||
parent = parent->parent;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue