From 3a7705bde67e4b437293f82ec6baa5b7a1fbf373 Mon Sep 17 00:00:00 2001 From: Catfriend1 Date: Sun, 10 Feb 2019 13:47:11 +0100 Subject: [PATCH] Fix NPE in offline config reader (fixes #316) after folder has been created while Syncthing was not running --- .../java/com/nutomic/syncthingandroid/util/ConfigXml.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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 397ecd38..21bea3bf 100644 --- a/app/src/main/java/com/nutomic/syncthingandroid/util/ConfigXml.java +++ b/app/src/main/java/com/nutomic/syncthingandroid/util/ConfigXml.java @@ -459,8 +459,10 @@ public class ConfigXml { */ 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); + if (elementMinDiskFree != null) { + 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