mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-16 09:57:19 -05:00
Fix error "(EE) SSGxsChannelGroup::load() asked to load a null string.
Weird." by creating a default serviceString if empty.
This commit is contained in:
parent
f5eb791230
commit
3c3d23bf8a
@ -514,20 +514,20 @@ bool p3GxsChannels::setChannelDownloadDirectory(const RsGxsGroupId &groupId, con
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool p3GxsChannels::getChannelDownloadDirectory(const RsGxsGroupId & id,std::string& directory)
|
bool p3GxsChannels::getChannelDownloadDirectory(const RsGxsGroupId & groupId,std::string& directory)
|
||||||
{
|
{
|
||||||
#ifdef GXSCHANNELS_DEBUG
|
#ifdef GXSCHANNELS_DEBUG
|
||||||
std::cerr << "p3GxsChannels::autoDownloadEnabled(" << id << ")" << std::endl;
|
std::cerr << "p3GxsChannels::getChannelDownloadDirectory(" << id << ")" << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
std::map<RsGxsGroupId, RsGroupMetaData>::iterator it;
|
std::map<RsGxsGroupId, RsGroupMetaData>::iterator it;
|
||||||
|
|
||||||
it = mSubscribedGroups.find(id);
|
it = mSubscribedGroups.find(groupId);
|
||||||
|
|
||||||
if (it == mSubscribedGroups.end())
|
if (it == mSubscribedGroups.end())
|
||||||
{
|
{
|
||||||
#ifdef GXSCHANNELS_DEBUG
|
#ifdef GXSCHANNELS_DEBUG
|
||||||
std::cerr << "p3GxsChannels::autoDownloadEnabled() No Entry" << std::endl;
|
std::cerr << "p3GxsChannels::getChannelDownloadDirectory() No Entry" << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@ -535,6 +535,26 @@ bool p3GxsChannels::getChannelDownloadDirectory(const RsGxsGroupId & id,std::str
|
|||||||
|
|
||||||
/* extract from ServiceString */
|
/* extract from ServiceString */
|
||||||
SSGxsChannelGroup ss;
|
SSGxsChannelGroup ss;
|
||||||
|
if (it->second.mServiceString.empty())
|
||||||
|
{
|
||||||
|
#ifdef GXSCHANNELS_DEBUG
|
||||||
|
std::cerr << "p3GxsChannels::getChannelDownloadDirectory() No ServiceString make new one." << std::endl;
|
||||||
|
#endif
|
||||||
|
std::string serviceString = ss.save();
|
||||||
|
uint32_t token;
|
||||||
|
|
||||||
|
it->second.mServiceString = serviceString; // update Local Cache.
|
||||||
|
RsGenExchange::setGroupServiceString(token, groupId, serviceString); // update dbase.
|
||||||
|
|
||||||
|
/* now reload it */
|
||||||
|
std::list<RsGxsGroupId> groups;
|
||||||
|
groups.push_back(groupId);
|
||||||
|
|
||||||
|
request_SpecificSubscribedGroups(groups);
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
ss.load(it->second.mServiceString);
|
ss.load(it->second.mServiceString);
|
||||||
directory = ss.mDownloadDirectory;
|
directory = ss.mDownloadDirectory;
|
||||||
|
|
||||||
@ -904,7 +924,7 @@ void p3GxsChannels::handleResponse(uint32_t token, uint32_t req_type)
|
|||||||
/********************************************************************************************/
|
/********************************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
bool p3GxsChannels::autoDownloadEnabled(const RsGxsGroupId &id,bool& enabled)
|
bool p3GxsChannels::autoDownloadEnabled(const RsGxsGroupId &groupId,bool& enabled)
|
||||||
{
|
{
|
||||||
#ifdef GXSCHANNELS_DEBUG
|
#ifdef GXSCHANNELS_DEBUG
|
||||||
std::cerr << "p3GxsChannels::autoDownloadEnabled(" << id << ")";
|
std::cerr << "p3GxsChannels::autoDownloadEnabled(" << id << ")";
|
||||||
@ -913,7 +933,7 @@ bool p3GxsChannels::autoDownloadEnabled(const RsGxsGroupId &id,bool& enabled)
|
|||||||
|
|
||||||
std::map<RsGxsGroupId, RsGroupMetaData>::iterator it;
|
std::map<RsGxsGroupId, RsGroupMetaData>::iterator it;
|
||||||
|
|
||||||
it = mSubscribedGroups.find(id);
|
it = mSubscribedGroups.find(groupId);
|
||||||
if (it == mSubscribedGroups.end())
|
if (it == mSubscribedGroups.end())
|
||||||
{
|
{
|
||||||
#ifdef GXSCHANNELS_DEBUG
|
#ifdef GXSCHANNELS_DEBUG
|
||||||
@ -926,10 +946,30 @@ bool p3GxsChannels::autoDownloadEnabled(const RsGxsGroupId &id,bool& enabled)
|
|||||||
|
|
||||||
/* extract from ServiceString */
|
/* extract from ServiceString */
|
||||||
SSGxsChannelGroup ss;
|
SSGxsChannelGroup ss;
|
||||||
ss.load(it->second.mServiceString);
|
if (it->second.mServiceString.empty())
|
||||||
enabled = ss.mAutoDownload;
|
{
|
||||||
|
#ifdef GXSCHANNELS_DEBUG
|
||||||
|
std::cerr << "p3GxsChannels::autoDownloadEnabled() No ServiceString make new one." << std::endl;
|
||||||
|
#endif
|
||||||
|
std::string serviceString = ss.save();
|
||||||
|
uint32_t token;
|
||||||
|
|
||||||
return true ;
|
it->second.mServiceString = serviceString; // update Local Cache.
|
||||||
|
RsGenExchange::setGroupServiceString(token, groupId, serviceString); // update dbase.
|
||||||
|
|
||||||
|
/* now reload it */
|
||||||
|
std::list<RsGxsGroupId> groups;
|
||||||
|
groups.push_back(groupId);
|
||||||
|
|
||||||
|
request_SpecificSubscribedGroups(groups);
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
ss.load(it->second.mServiceString);
|
||||||
|
enabled = ss.mAutoDownload;
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SSGxsChannelGroup::load(const std::string &input)
|
bool SSGxsChannelGroup::load(const std::string &input)
|
||||||
|
@ -45,12 +45,12 @@
|
|||||||
class SSGxsChannelGroup
|
class SSGxsChannelGroup
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
SSGxsChannelGroup(): mAutoDownload(false), mDownloadDirectory("") {}
|
||||||
bool load(const std::string &input);
|
bool load(const std::string &input);
|
||||||
std::string save() const;
|
std::string save() const;
|
||||||
|
|
||||||
bool mAutoDownload;
|
bool mAutoDownload;
|
||||||
std::string mDownloadDirectory ;
|
std::string mDownloadDirectory;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -176,7 +176,7 @@ static uint32_t channelsAuthenPolicy();
|
|||||||
void updateSubscribedGroup(const RsGroupMetaData &group);
|
void updateSubscribedGroup(const RsGroupMetaData &group);
|
||||||
void clearUnsubscribedGroup(const RsGxsGroupId &id);
|
void clearUnsubscribedGroup(const RsGxsGroupId &id);
|
||||||
bool setAutoDownload(const RsGxsGroupId &groupId, bool enabled);
|
bool setAutoDownload(const RsGxsGroupId &groupId, bool enabled);
|
||||||
bool autoDownloadEnabled(const RsGxsGroupId &id, bool &enabled);
|
bool autoDownloadEnabled(const RsGxsGroupId &groupId, bool &enabled);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user