1
0
Fork 0
mirror of https://github.com/syncthing/syncthing-android.git synced 2025-01-11 04:25:53 +00:00

Enforce single hasher (fixes #384)

This commit is contained in:
Lode Hoste 2015-05-05 22:03:05 +02:00
parent 79f0e2a8dc
commit 75bdc12a0f

View file

@ -141,6 +141,10 @@ public class ConfigXml {
if (applyLenientMTimes(r)) { if (applyLenientMTimes(r)) {
changed = true; changed = true;
} }
if (applyHashers(r)) {
changed = true;
}
} }
// Enforce TLS. // Enforce TLS.
@ -196,6 +200,33 @@ public class ConfigXml {
return true; 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() { private Element getGuiElement() {
return (Element) mConfig.getDocumentElement() return (Element) mConfig.getDocumentElement()
.getElementsByTagName("gui").item(0); .getElementsByTagName("gui").item(0);