diff --git a/app/src/main/java/com/nutomic/syncthingandroid/activities/FolderActivity.java b/app/src/main/java/com/nutomic/syncthingandroid/activities/FolderActivity.java
index 140d9457..18507367 100644
--- a/app/src/main/java/com/nutomic/syncthingandroid/activities/FolderActivity.java
+++ b/app/src/main/java/com/nutomic/syncthingandroid/activities/FolderActivity.java
@@ -655,6 +655,7 @@ public class FolderActivity extends SyncthingActivity {
mFolder.rescanIntervalS = 3600;
mFolder.paused = false;
mFolder.type = Constants.FOLDER_TYPE_SEND_RECEIVE; // Default for {@link #checkWriteAndUpdateUI}.
+ mFolder.minDiskFree = new Folder.MinDiskFree();
mFolder.versioning = new Folder.Versioning();
}
diff --git a/app/src/main/java/com/nutomic/syncthingandroid/model/Folder.java b/app/src/main/java/com/nutomic/syncthingandroid/model/Folder.java
index 407d6dee..aca5d527 100644
--- a/app/src/main/java/com/nutomic/syncthingandroid/model/Folder.java
+++ b/app/src/main/java/com/nutomic/syncthingandroid/model/Folder.java
@@ -51,8 +51,8 @@ public class Folder {
}
public static class MinDiskFree {
- public float value;
- public String unit;
+ public float value = 1;
+ public String unit = "%";
}
public void addDevice(final Device device) {
diff --git a/app/src/main/java/com/nutomic/syncthingandroid/model/Options.java b/app/src/main/java/com/nutomic/syncthingandroid/model/Options.java
index ff09fc6b..d1e50763 100644
--- a/app/src/main/java/com/nutomic/syncthingandroid/model/Options.java
+++ b/app/src/main/java/com/nutomic/syncthingandroid/model/Options.java
@@ -29,16 +29,23 @@ public class Options {
public int progressUpdateIntervalS;
public boolean symlinksEnabled;
public boolean limitBandwidthInLan;
- public int minHomeDiskFreePct;
public String releasesURL;
public String[] alwaysLocalNets;
public boolean overwriteRemoteDeviceNamesOnConnect;
public int tempIndexMinBlocks;
public String defaultFolderPath;
+ // Since v0.14.28, Issue #3307, PR #4087
+ public MinHomeDiskFree minHomeDiskFree;
+
// Since v1.0.0, see https://github.com/syncthing/syncthing/pull/4888
public int maxConcurrentScans;
+ public static class MinHomeDiskFree {
+ public float value = 1;
+ public String unit = "%";
+ }
+
public static final int USAGE_REPORTING_UNDECIDED = 0;
public static final int USAGE_REPORTING_DENIED = -1;
diff --git a/app/src/main/java/com/nutomic/syncthingandroid/util/ConfigXml.java b/app/src/main/java/com/nutomic/syncthingandroid/util/ConfigXml.java
index 1ce2f020..ac9c86c3 100644
--- a/app/src/main/java/com/nutomic/syncthingandroid/util/ConfigXml.java
+++ b/app/src/main/java/com/nutomic/syncthingandroid/util/ConfigXml.java
@@ -446,6 +446,16 @@ public class ConfigXml {
}
}
+ // MinDiskFree
+ /*
+ 5
+ */
+ folder.minDiskFree = new Folder.MinDiskFree();
+ Element elementMinDiskFree = (Element) r.getElementsByTagName("minDiskFree").item(0);
+ folder.minDiskFree.unit = getAttributeOrDefault(elementMinDiskFree, "unit", "%");
+ folder.minDiskFree.value = getContentOrDefault(elementMinDiskFree, 1f);
+ // Log.v(TAG, "folder.minDiskFree.unit=" + folder.minDiskFree.unit + ", folder.minDiskFree.value=" + folder.minDiskFree.value);
+
// Versioning
/*
@@ -533,8 +543,25 @@ public class ConfigXml {
elementDevice.setAttribute("introducedBy", device.introducedBy);
}
+ // minDiskFree
+ if (folder.minDiskFree != null) {
+ // Pass 1: Remove all minDiskFree nodes from XML (usually one)
+ Element elementMinDiskFree = (Element) r.getElementsByTagName("minDiskFree").item(0);
+ if (elementMinDiskFree != null) {
+ Log.v(TAG, "updateFolder: nodeMinDiskFree: Removing minDiskFree node");
+ removeChildElementFromTextNode(r, elementMinDiskFree);
+ }
+
+ // Pass 2: Add minDiskFree node from the POJO model to XML.
+ Node nodeMinDiskFree = mConfig.createElement("minDiskFree");
+ r.appendChild(nodeMinDiskFree);
+ elementMinDiskFree = (Element) nodeMinDiskFree;
+ elementMinDiskFree.setAttribute("unit", folder.minDiskFree.unit);
+ setConfigElement(r, "minDiskFree", Float.toString(folder.minDiskFree.value));
+ }
+
// Versioning
- // Pass 1: Remove all versioning nodes in XML (usually one)
+ // Pass 1: Remove all versioning nodes from XML (usually one)
/*
NodeList nlVersioning = r.getElementsByTagName("versioning");
for (int j = nlVersioning.getLength() - 1; j >= 0; j--) {
@@ -548,7 +575,7 @@ public class ConfigXml {
removeChildElementFromTextNode(r, elementVersioning);
}
- // Pass 2: Add versioning node from the POJO model.
+ // Pass 2: Add versioning node from the POJO model to XML.
Node nodeVersioning = mConfig.createElement("versioning");
r.appendChild(nodeVersioning);
elementVersioning = (Element) nodeVersioning;