Logdir: change the logdir and add context info (MB #8350)
The Logdir has no info about context and is not normalized. This will have problem when the peer name has arbitrary characters. Normalize the peer name and adding context info in the log dir. This could help find the corresponding config and look up the 'PeerName' in the config for sync ui.
This commit is contained in:
parent
3578ce4241
commit
67539a7872
|
@ -1514,6 +1514,12 @@ void ReadOperations::getReports(uint32_t start, uint32_t count,
|
|||
SyncReport report;
|
||||
// peerName is also extracted from the dir
|
||||
string peerName = client.readSessionInfo(dir,report);
|
||||
boost::shared_ptr<SyncConfig> config(new SyncConfig(m_configName));
|
||||
string storedPeerName = config->getPeerName();
|
||||
//if can't find peer name, use the peer name from the log dir
|
||||
if(!storedPeerName.empty()) {
|
||||
peerName = storedPeerName;
|
||||
}
|
||||
|
||||
/** serialize report to ConfigProps and then copy them to reports */
|
||||
HashFileConfigNode node("/dev/null","",true);
|
||||
|
|
|
@ -187,20 +187,22 @@ class LogDir : public LoggerBase {
|
|||
m_logdir = boost::trim_right_copy_if(logdir, boost::is_any_of("/"));
|
||||
|
||||
string lower = m_client.getServer();
|
||||
string context, peer;
|
||||
SyncConfig::splitConfigString(lower, peer, context);
|
||||
string context, peer, normal;
|
||||
SyncConfig::normalizeConfigString(lower, normal, context);
|
||||
SyncConfig::splitConfigString(normal, peer, context);
|
||||
|
||||
boost::to_lower(peer);
|
||||
// escape "_" and "-" the peer name
|
||||
peer = escapePeerName(peer);
|
||||
string full = peer + "@";
|
||||
full += context;
|
||||
|
||||
if (boost::iends_with(m_logdir, "syncevolution")) {
|
||||
// use just the server name as prefix
|
||||
m_prefix = peer;
|
||||
m_prefix = full;
|
||||
} else {
|
||||
// SyncEvolution-<server>-<yyyy>-<mm>-<dd>-<hh>-<mm>
|
||||
m_prefix = DIR_PREFIX;
|
||||
m_prefix += peer;
|
||||
m_prefix += full;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -567,7 +569,7 @@ private:
|
|||
|
||||
/**
|
||||
* parse a directory name into dirPrefix(empty or DIR_PREFIX), peerName, dateTime.
|
||||
* If directory name is in the format of '[DIR_PREFIX]-peerName-year-month-day-hour-min'
|
||||
* If directory name is in the format of '[DIR_PREFIX]-peerName@context-year-month-day-hour-min'
|
||||
* then parsing is sucessful and these 3 strings are correctly set and true is returned.
|
||||
* Otherwise, false is returned.
|
||||
* Here we don't check whether the dir name is matching peer name
|
||||
|
@ -605,7 +607,8 @@ private:
|
|||
// if directory name could not be parsed, ignore it
|
||||
if(parseDirName(entry, dirPrefix, peerName, dateTime)) {
|
||||
// if directory name is not satisfied with m_prefix, ignore it
|
||||
if (m_prefix == dirPrefix || m_prefix == (dirPrefix + peerName)) {
|
||||
if (m_prefix == dirPrefix || m_prefix == (dirPrefix + peerName)
|
||||
|| m_prefix == (dirPrefix + peerName + "@default")) {
|
||||
dirs.push_back(m_logdir + "/" + entry);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue