commit 21cb7eb2051fd12538d0e852220d614753b1407e Author: Tomás Touceda chiiph@torproject.org Date: Thu Jun 28 20:50:22 2012 -0300
Don't write torrc options with default values --- changes/bug6178 | 2 ++ src/vidalia/config/torrc/Torrc.cpp | 19 ++++++++++++++++++- 2 files changed, 20 insertions(+), 1 deletions(-)
diff --git a/changes/bug6178 b/changes/bug6178 new file mode 100644 index 0000000..910ef8e --- /dev/null +++ b/changes/bug6178 @@ -0,0 +1,2 @@ + Bugfixes relative to Vidalia 0.3.x: + o Don't write values that are default in torrc. Fixes bug 6178. diff --git a/src/vidalia/config/torrc/Torrc.cpp b/src/vidalia/config/torrc/Torrc.cpp index 18dd64d..8a7be47 100644 --- a/src/vidalia/config/torrc/Torrc.cpp +++ b/src/vidalia/config/torrc/Torrc.cpp @@ -54,6 +54,12 @@ Torrc::apply(TorControl *tc, QString *errmsg) QString current_line;
foreach(TorrcLine *line, _lines) { + if (line->content().trimmed().length() > 0) { + TorOpt currentOpt = _parser.getTorOpt(line->content().split(" ")[0]); + // Skip default values + if(not currentOpt.isMultilined() and currentOpt.defaultValue() == _torrcMap.value(currentOpt.name()).first) + continue; + } torrc_contents += QString("%1 %2") .arg(line->content()) .arg(line->comment()).trimmed(); @@ -138,12 +144,23 @@ Torrc::setValue(const QString &key, const QString &value, const QString &comment if(not key.isEmpty() and value.isEmpty()) return;
+ TorOpt currentOpt = _parser.getTorOpt(key); + if(currentOpt.isNull()) + return; + if(_defaultsMap.contains(key)) { QPair<QString,TorOpt> defvalue; foreach(defvalue, _defaultsMap.values(key)) { - if(defvalue.first == value) + if(defvalue.first == value) { + if(not currentOpt.isMultivalued()) + clear(QStringList() << key); return; + } } + } else if(currentOpt.defaultValue() == value) { + if(not currentOpt.isMultivalued()) + clear(QStringList() << key); + return; }
if(_torrcMap.contains(key)) {
tor-commits@lists.torproject.org