mirror of
https://github.com/syncthing/syncthing-android.git
synced 2024-11-26 22:31:16 +00:00
Set lenientMtimes
option on all folders (fixes #146).
See syncthing/syncthing#831.
This commit is contained in:
parent
560d7bf97a
commit
a000eda4e4
2 changed files with 35 additions and 0 deletions
|
@ -181,6 +181,8 @@ public class SyncthingService extends Service {
|
|||
mApi.shutdown();
|
||||
|
||||
Log.i(TAG, "Starting syncthing according to current state and preferences");
|
||||
mConfig = new ConfigXml(SyncthingService.this);
|
||||
mConfig.updateIfNeeded();
|
||||
mCurrentState = State.STARTING;
|
||||
registerOnWebGuiAvailableListener(mApi);
|
||||
new PollWebGuiAvailableTaskImpl().execute(mConfig.getWebGuiUrl());
|
||||
|
|
|
@ -129,6 +129,10 @@ public class ConfigXml {
|
|||
r.setAttribute("directory", newDir);
|
||||
changed = true;
|
||||
}
|
||||
|
||||
if (applyLenientMTimes(r)) {
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Change global announce server port to 22026 for syncthing v0.9.0.
|
||||
|
@ -143,6 +147,35 @@ public class ConfigXml {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set 'lenientMtimes' (see https://github.com/syncthing/syncthing/issues/831) on the
|
||||
* given folder.
|
||||
*
|
||||
* @return True if the XML was changed.
|
||||
*/
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
private Element getGuiElement() {
|
||||
return (Element) mConfig.getDocumentElement()
|
||||
.getElementsByTagName("gui").item(0);
|
||||
|
|
Loading…
Reference in a new issue