From f4565c1bb05defa035be13f66e49be71763e45ab Mon Sep 17 00:00:00 2001 From: Felix Ableitner Date: Thu, 16 Oct 2014 13:02:24 +0300 Subject: [PATCH] lenientMtimes option seems to be false in some cases. --- .../syncthingandroid/util/ConfigXml.java | 27 +++++++++---------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/src/main/java/com/nutomic/syncthingandroid/util/ConfigXml.java b/src/main/java/com/nutomic/syncthingandroid/util/ConfigXml.java index 7730a2cc..663ef994 100644 --- a/src/main/java/com/nutomic/syncthingandroid/util/ConfigXml.java +++ b/src/main/java/com/nutomic/syncthingandroid/util/ConfigXml.java @@ -8,6 +8,7 @@ import com.nutomic.syncthingandroid.R; import org.w3c.dom.Document; import org.w3c.dom.Element; +import org.w3c.dom.Node; import org.w3c.dom.NodeList; import org.xml.sax.SAXException; @@ -155,25 +156,23 @@ public class ConfigXml { */ private boolean applyLenientMTimes(Element folder) { NodeList childs = folder.getChildNodes(); - boolean lenientMTimesSet = false; for (int i = 0; i < childs.getLength(); i++) { - if (childs.item(i).getNodeName().equals("lenientMtimes")) { - // Already set, do nothing (we assume that it is set to true, because nothing could - // change it (no GUI option). - lenientMTimesSet = true; - break; + Node item = childs.item(i); + if (item.getNodeName().equals("lenientMtimes")) { + if (item.getTextContent().equals(Boolean.toString(false))) { + item.setTextContent(Boolean.toString(true)); + return true; + } + return false; } } // XML tag does not exist, create it. - if (!lenientMTimesSet) { - Log.i(TAG, "Set 'lenientMtimes' on folder " + folder.getAttribute("id")); - Element newElem = mConfig.createElement("lenientMtimes"); - newElem.setTextContent(Boolean.toString(true)); - folder.appendChild(newElem); - return true; - } - return false; + Log.i(TAG, "Set 'lenientMtimes' on folder " + folder.getAttribute("id")); + Element newElem = mConfig.createElement("lenientMtimes"); + newElem.setTextContent(Boolean.toString(true)); + folder.appendChild(newElem); + return true; } private Element getGuiElement() {