mirror of
https://github.com/RetroShare/libretroshare.git
synced 2026-09-12 19:50:03 +05:00
merged and fixed conflict with upstream/master
This commit is contained in:
commit
46f3fd7e95
@ -299,8 +299,7 @@ bool InternalFileHierarchyStorage::updateSubFilesList(const DirectoryStorage::En
|
||||
std::cerr << "[directory storage] removing non existing file " << f.file_name << " at index " << d.subfiles[i] << std::endl;
|
||||
#endif
|
||||
|
||||
delete mNodes[d.subfiles[i]] ;
|
||||
mNodes[d.subfiles[i]] = NULL ;
|
||||
deleteNode(d.subfiles[i]) ;
|
||||
|
||||
d.subfiles[i] = d.subfiles[d.subfiles.size()-1] ;
|
||||
d.subfiles.pop_back();
|
||||
@ -374,23 +373,29 @@ bool InternalFileHierarchyStorage::updateFile(const DirectoryStorage::EntryIndex
|
||||
return true;
|
||||
}
|
||||
|
||||
void InternalFileHierarchyStorage::deleteNode(uint32_t index)
|
||||
{
|
||||
if(mNodes[index] != NULL)
|
||||
{
|
||||
delete mNodes[index] ;
|
||||
mFreeNodes.push_back(index) ;
|
||||
mNodes[index] = NULL ;
|
||||
}
|
||||
}
|
||||
|
||||
DirectoryStorage::EntryIndex InternalFileHierarchyStorage::allocateNewIndex()
|
||||
{
|
||||
int found = -1;
|
||||
for(uint32_t j=0;j<mNodes.size();++j)
|
||||
if(mNodes[j] == NULL)
|
||||
{
|
||||
found = j;
|
||||
break;
|
||||
}
|
||||
|
||||
if(found < 0)
|
||||
while(!mFreeNodes.empty())
|
||||
{
|
||||
mNodes.push_back(NULL) ;
|
||||
return mNodes.size()-1 ;
|
||||
uint32_t index = mFreeNodes.front();
|
||||
mFreeNodes.pop_front();
|
||||
|
||||
if(mNodes[index] == NULL)
|
||||
return DirectoryStorage::EntryIndex(index) ;
|
||||
}
|
||||
else
|
||||
return found ;
|
||||
|
||||
mNodes.push_back(NULL) ;
|
||||
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)
|
||||
@ -534,8 +539,7 @@ bool InternalFileHierarchyStorage::updateDirEntry(const DirectoryStorage::EntryI
|
||||
std::cerr << "(EE) Cannot delete node of index " << it->second << " because it is not a file. Inconsistency error!" << std::endl;
|
||||
continue ;
|
||||
}
|
||||
delete mNodes[it->second] ;
|
||||
mNodes[it->second] = NULL ;
|
||||
deleteNode(it->second) ;
|
||||
}
|
||||
|
||||
// now update row and parent index for all subnodes
|
||||
@ -740,6 +744,8 @@ bool InternalFileHierarchyStorage::check(std::string& error_string) // checks co
|
||||
std::vector<uint32_t> hits(mNodes.size(),0) ; // count hits of children. Should be 1 for all in the end. Otherwise there's an error.
|
||||
hits[0] = 1 ; // because 0 is never the child of anyone
|
||||
|
||||
mFreeNodes.clear();
|
||||
|
||||
for(uint32_t i=0;i<mNodes.size();++i)
|
||||
if(mNodes[i] != NULL && mNodes[i]->type() == FileStorageNode::TYPE_DIR)
|
||||
{
|
||||
@ -787,13 +793,15 @@ bool InternalFileHierarchyStorage::check(std::string& error_string) // checks co
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(mNodes[i] == NULL)
|
||||
mFreeNodes.push_back(i) ;
|
||||
|
||||
for(uint32_t i=0;i<hits.size();++i)
|
||||
if(hits[i] == 0 && mNodes[i] != NULL)
|
||||
{
|
||||
error_string += " - Orphean node!" ;
|
||||
delete mNodes[i] ;
|
||||
mNodes[i] = NULL ;
|
||||
|
||||
deleteNode(i) ;
|
||||
}
|
||||
|
||||
return error_string.empty();;
|
||||
@ -887,12 +895,9 @@ bool InternalFileHierarchyStorage::recursRemoveDirectory(DirectoryStorage::Entry
|
||||
recursRemoveDirectory(d.subdirs[i]);
|
||||
|
||||
for(uint32_t i=0;i<d.subfiles.size();++i)
|
||||
{
|
||||
delete mNodes[d.subfiles[i]] ;
|
||||
mNodes[d.subfiles[i]] = NULL ;
|
||||
}
|
||||
delete mNodes[dir] ;
|
||||
mNodes[dir] = NULL ;
|
||||
deleteNode(d.subfiles[i]);
|
||||
|
||||
deleteNode(dir) ;
|
||||
|
||||
mDirHashes.erase(hash) ;
|
||||
|
||||
@ -1005,6 +1010,8 @@ bool InternalFileHierarchyStorage::load(const std::string& fname)
|
||||
uint32_t buffer_size = 0 ;
|
||||
uint32_t buffer_offset = 0 ;
|
||||
|
||||
mFreeNodes.clear();
|
||||
|
||||
try
|
||||
{
|
||||
if(!FileListIO::loadEncryptedDataFromFile(fname,buffer,buffer_size) )
|
||||
|
||||
@ -122,6 +122,7 @@ public:
|
||||
bool findSubDirectory(DirectoryStorage::EntryIndex e,const std::string& s) const ; // returns true when s is the name of a sub-directory in the given entry e
|
||||
|
||||
uint32_t mRoot ;
|
||||
std::list<uint32_t > mFreeNodes ; // keeps a list of free nodes in order to make insert effcieint
|
||||
std::vector<FileStorageNode*> mNodes;// uses pointers to keep information about valid/invalid objects.
|
||||
|
||||
void compress() ; // use empty space in the vector, mostly due to deleted entries. This is a complicated operation, mostly due to
|
||||
@ -159,6 +160,10 @@ private:
|
||||
|
||||
DirectoryStorage::EntryIndex allocateNewIndex();
|
||||
|
||||
// Deletes an existing entry in mNodes, and keeps record of the indices that get freed.
|
||||
|
||||
void deleteNode(DirectoryStorage::EntryIndex);
|
||||
|
||||
// Removes the given subdirectory from the parent node and all its pendign subdirs. Files are kept, and will go during the cleaning
|
||||
// phase. That allows to keep file information when moving them around.
|
||||
|
||||
|
||||
@ -542,7 +542,7 @@ uint32_t p3FileDatabase::locked_getFriendIndex(const RsPeerId& pid)
|
||||
mUpdateFlags |= P3FILELISTS_UPDATE_FLAG_REMOTE_MAP_CHANGED ;
|
||||
|
||||
#ifdef DEBUG_P3FILELISTS
|
||||
P3FILELISTS_DEBUG() << " adding missing remote dir entry for friend " << *it << ", with index " << friend_index << std::endl;
|
||||
P3FILELISTS_DEBUG() << " adding missing remote dir entry for friend " << pid << ", with index " << it->second << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -569,7 +569,7 @@ uint32_t p3FileDatabase::locked_getFriendIndex(const RsPeerId& pid)
|
||||
mUpdateFlags |= P3FILELISTS_UPDATE_FLAG_REMOTE_MAP_CHANGED ;
|
||||
|
||||
#ifdef DEBUG_P3FILELISTS
|
||||
P3FILELISTS_DEBUG() << " adding missing remote dir entry for friend " << *it << ", with index " << friend_index << std::endl;
|
||||
P3FILELISTS_DEBUG() << " adding missing remote dir entry for friend " << pid << ", with index " << it->second << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@ -295,7 +295,7 @@ mac {
|
||||
OBJECTS_DIR = temp/obj
|
||||
MOC_DIR = temp/moc
|
||||
#DEFINES = WINDOWS_SYS WIN32 STATICLIB MINGW
|
||||
DEFINES *= MINIUPNPC_VERSION=13
|
||||
#DEFINES *= MINIUPNPC_VERSION=13
|
||||
|
||||
CONFIG += upnp_miniupnpc
|
||||
CONFIG += c++11
|
||||
@ -305,7 +305,7 @@ mac {
|
||||
#CONFIG += zcnatassist
|
||||
|
||||
# Beautiful Hack to fix 64bit file access.
|
||||
QMAKE_CXXFLAGS *= -Dfseeko64=fseeko -Dftello64=ftello -Dfopen64=fopen -Dvstatfs64=vstatfs
|
||||
QMAKE_CXXFLAGS *= -Dfseeko64=fseeko -Dftello64=ftello -Dfopen64=fopen -Dvstatfs64=vstatfs
|
||||
|
||||
#GPG_ERROR_DIR = ../../../../libgpg-error-1.7
|
||||
#GPGME_DIR = ../../../../gpgme-1.1.8
|
||||
@ -315,6 +315,7 @@ mac {
|
||||
|
||||
DEPENDPATH += . $$INC_DIR
|
||||
INCLUDEPATH += . $$INC_DIR
|
||||
INCLUDEPATH += ../../../.
|
||||
|
||||
# We need a explicit path here, to force using the home version of sqlite3 that really encrypts the database.
|
||||
LIBS += /usr/local/lib/libsqlcipher.a
|
||||
|
||||
@ -30,7 +30,17 @@
|
||||
#include <iostream>
|
||||
#include <time.h>
|
||||
|
||||
#ifdef __APPLE__
|
||||
int __attribute__((weak)) pthread_setname_np(const char *__buf) ;
|
||||
int RS_pthread_setname_np(pthread_t /*__target_thread*/, const char *__buf) {
|
||||
return pthread_setname_np(__buf);
|
||||
}
|
||||
#else
|
||||
int __attribute__((weak)) pthread_setname_np(pthread_t __target_thread, const char *__buf) ;
|
||||
int RS_pthread_setname_np(pthread_t __target_thread, const char *__buf) {
|
||||
return pthread_setname_np(__target_thread, __buf);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef RSMUTEX_DEBUG
|
||||
#include <stdio.h>
|
||||
@ -167,19 +177,21 @@ void RsThread::start(const std::string &threadName)
|
||||
// set name
|
||||
|
||||
if(pthread_setname_np)
|
||||
if(!threadName.empty())
|
||||
{
|
||||
// thread names are restricted to 16 characters including the terminating null byte
|
||||
if(threadName.length() > 15)
|
||||
{
|
||||
{
|
||||
if(!threadName.empty())
|
||||
{
|
||||
// thread names are restricted to 16 characters including the terminating null byte
|
||||
if(threadName.length() > 15)
|
||||
{
|
||||
#ifdef DEBUG_THREADS
|
||||
THREAD_DEBUG << "RsThread::start called with to long name '" << name << "' truncating..." << std::endl;
|
||||
THREAD_DEBUG << "RsThread::start called with to long name '" << name << "' truncating..." << std::endl;
|
||||
#endif
|
||||
pthread_setname_np(mTid, threadName.substr(0, 15).c_str());
|
||||
} else {
|
||||
pthread_setname_np(mTid, threadName.c_str());
|
||||
}
|
||||
}
|
||||
RS_pthread_setname_np(mTid, threadName.substr(0, 15).c_str());
|
||||
} else {
|
||||
RS_pthread_setname_np(mTid, threadName.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@ -182,33 +182,40 @@ win32 {
|
||||
################################# MacOSX ##########################################
|
||||
|
||||
mac {
|
||||
QMAKE_CC = $${QMAKE_CXX}
|
||||
OBJECTS_DIR = temp/obj
|
||||
MOC_DIR = temp/moc
|
||||
#DEFINES = WINDOWS_SYS WIN32 STATICLIB MINGW
|
||||
#DEFINES *= MINIUPNPC_VERSION=13
|
||||
DESTDIR = lib
|
||||
QMAKE_CC = $${QMAKE_CXX}
|
||||
OBJECTS_DIR = temp/obj
|
||||
MOC_DIR = temp/moc
|
||||
#DEFINES = WINDOWS_SYS WIN32 STATICLIB MINGW
|
||||
#DEFINES *= MINIUPNPC_VERSION=13
|
||||
DESTDIR = lib
|
||||
|
||||
CONFIG += upnp_miniupnpc
|
||||
CONFIG += upnp_miniupnpc
|
||||
|
||||
# zeroconf disabled at the end of libretroshare.pro (but need the code)
|
||||
CONFIG += zeroconf
|
||||
CONFIG += zcnatassist
|
||||
# zeroconf disabled at the end of libretroshare.pro (but need the code)
|
||||
#CONFIG += zeroconf
|
||||
#CONFIG += zcnatassist
|
||||
|
||||
# Beautiful Hack to fix 64bit file access.
|
||||
QMAKE_CXXFLAGS *= -Dfseeko64=fseeko -Dftello64=ftello -Dfopen64=fopen -Dvstatfs64=vstatfs
|
||||
# Beautiful Hack to fix 64bit file access.
|
||||
QMAKE_CXXFLAGS *= -Dfseeko64=fseeko -Dftello64=ftello -Dfopen64=fopen -Dvstatfs64=vstatfs
|
||||
|
||||
UPNPC_DIR = ../../../miniupnpc-1.0
|
||||
#GPG_ERROR_DIR = ../../../../libgpg-error-1.7
|
||||
#GPGME_DIR = ../../../../gpgme-1.1.8
|
||||
#UPNPC_DIR = ../../../miniupnpc-1.0
|
||||
#GPG_ERROR_DIR = ../../../../libgpg-error-1.7
|
||||
#GPGME_DIR = ../../../../gpgme-1.1.8
|
||||
#OPENPGPSDK_DIR = ../../openpgpsdk/src
|
||||
#INCLUDEPATH += . $${UPNPC_DIR}
|
||||
#INCLUDEPATH += $${OPENPGPSDK_DIR}
|
||||
|
||||
OPENPGPSDK_DIR = ../../openpgpsdk/src
|
||||
#for(lib, LIB_DIR):exists($$lib/libminiupnpc.a){ LIBS += $$lib/libminiupnpc.a}
|
||||
for(lib, LIB_DIR):LIBS += -L"$$lib"
|
||||
for(bin, BIN_DIR):LIBS += -L"$$bin"
|
||||
|
||||
INCLUDEPATH += . $${UPNPC_DIR}
|
||||
INCLUDEPATH += $${OPENPGPSDK_DIR}
|
||||
DEPENDPATH += . $$INC_DIR
|
||||
INCLUDEPATH += . $$INC_DIR
|
||||
INCLUDEPATH += ../../../.
|
||||
|
||||
#../openpgpsdk
|
||||
#INCLUDEPATH += . $${UPNPC_DIR} $${GPGME_DIR}/src $${GPG_ERROR_DIR}/src
|
||||
# We need a explicit path here, to force using the home version of sqlite3 that really encrypts the database.
|
||||
LIBS += /usr/local/lib/libsqlcipher.a
|
||||
#LIBS += -lsqlite3
|
||||
}
|
||||
|
||||
################################# FreeBSD ##########################################
|
||||
|
||||
@ -171,34 +171,35 @@ win32 {
|
||||
##################################### MacOS ######################################
|
||||
|
||||
macx {
|
||||
# ENABLE THIS OPTION FOR Univeral Binary BUILD.
|
||||
CONFIG += ppc x86
|
||||
QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.4
|
||||
# ENABLE THIS OPTION FOR Univeral Binary BUILD.
|
||||
#CONFIG += ppc x86
|
||||
#QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.4
|
||||
|
||||
CONFIG += version_detail_bash_script
|
||||
LIBS += ../../libretroshare/src/lib/libretroshare.a
|
||||
LIBS += ../librssimulator/lib/librssimulator.a
|
||||
LIBS += ../../openpgpsdk/src/lib/libops.a -lbz2
|
||||
LIBS += -lssl -lcrypto -lz
|
||||
#LIBS += -lssl -lcrypto -lz -lgpgme -lgpg-error -lassuan
|
||||
LIBS += ../../../miniupnpc-1.0/libminiupnpc.a
|
||||
LIBS += -lssl -lcrypto -lz
|
||||
#LIBS += -lssl -lcrypto -lz -lgpgme -lgpg-error -lassuan
|
||||
for(lib, LIB_DIR):exists($$lib/libminiupnpc.a){ LIBS += $$lib/libminiupnpc.a}
|
||||
LIBS += -framework CoreFoundation
|
||||
LIBS += -framework Security
|
||||
|
||||
gxs {
|
||||
LIBS += ../../supportlibs/pegmarkdown/lib/libpegmarkdown.a
|
||||
|
||||
LIBS += ../../../lib/libsqlcipher.a
|
||||
#LIBS += -lsqlite3
|
||||
for(lib, LIB_DIR):LIBS += -L"$$lib"
|
||||
for(bin, BIN_DIR):LIBS += -L"$$bin"
|
||||
|
||||
}
|
||||
DEPENDPATH += . $$INC_DIR
|
||||
INCLUDEPATH += . $$INC_DIR
|
||||
|
||||
#LIBS += ../../supportlibs/pegmarkdown/lib/libpegmarkdown.a
|
||||
|
||||
# We need a explicit path here, to force using the home version of sqlite3 that really encrypts the database.
|
||||
LIBS += /usr/local/lib/libsqlcipher.a
|
||||
#LIBS += -lsqlite3
|
||||
|
||||
INCLUDEPATH += .
|
||||
#DEFINES* = MAC_IDLE # for idle feature
|
||||
CONFIG -= uitools
|
||||
|
||||
|
||||
}
|
||||
|
||||
##################################### FreeBSD ######################################
|
||||
|
||||
Loading…
Reference in New Issue
Block a user