mirror of
https://github.com/syncthing/syncthing-android.git
synced 2025-01-10 20:15:54 +00:00
Enforce single hasher (fixes #384)
This commit is contained in:
parent
79f0e2a8dc
commit
75bdc12a0f
1 changed files with 31 additions and 0 deletions
|
@ -141,6 +141,10 @@ public class ConfigXml {
|
|||
if (applyLenientMTimes(r)) {
|
||||
changed = true;
|
||||
}
|
||||
|
||||
if (applyHashers(r)) {
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Enforce TLS.
|
||||
|
@ -196,6 +200,33 @@ public class ConfigXml {
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set 'hashers' (see https://github.com/syncthing/syncthing-android/issues/384) on the
|
||||
* given folder.
|
||||
*
|
||||
* @return True if the XML was changed.
|
||||
*/
|
||||
private boolean applyHashers(Element folder) {
|
||||
NodeList childs = folder.getChildNodes();
|
||||
for (int i = 0; i < childs.getLength(); i++) {
|
||||
Node item = childs.item(i);
|
||||
if (item.getNodeName().equals("hashers")) {
|
||||
if (item.getTextContent().equals(Integer.toString(0))) {
|
||||
item.setTextContent(Integer.toString(1));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// XML tag does not exist, create it.
|
||||
Log.i(TAG, "Set 'hashers' on folder " + folder.getAttribute("id"));
|
||||
Element newElem = mConfig.createElement("hashers");
|
||||
newElem.setTextContent(Integer.toString(1));
|
||||
folder.appendChild(newElem);
|
||||
return true;
|
||||
}
|
||||
|
||||
private Element getGuiElement() {
|
||||
return (Element) mConfig.getDocumentElement()
|
||||
.getElementsByTagName("gui").item(0);
|
||||
|
|
Loading…
Reference in a new issue