From 12f7b3dbe2e98270c6bb4db08a4b1e0eb15cff3f Mon Sep 17 00:00:00 2001 From: Felix Ableitner Date: Thu, 9 Oct 2014 00:17:07 +0300 Subject: [PATCH] Fixed crash when receiving file move or create event (fixes #144). --- .../syncthingandroid/test/util/FolderObserverTest.java | 1 + .../com/nutomic/syncthingandroid/util/FolderObserver.java | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/androidTest/java/com/nutomic/syncthingandroid/test/util/FolderObserverTest.java b/src/androidTest/java/com/nutomic/syncthingandroid/test/util/FolderObserverTest.java index 28b7911e..4af77ca4 100644 --- a/src/androidTest/java/com/nutomic/syncthingandroid/test/util/FolderObserverTest.java +++ b/src/androidTest/java/com/nutomic/syncthingandroid/test/util/FolderObserverTest.java @@ -2,6 +2,7 @@ package com.nutomic.syncthingandroid.test.util; import android.test.AndroidTestCase; import android.test.suitebuilder.annotation.MediumTest; +import android.test.suitebuilder.annotation.SmallTest; import com.nutomic.syncthingandroid.syncthing.RestApi; import com.nutomic.syncthingandroid.test.MockContext; diff --git a/src/main/java/com/nutomic/syncthingandroid/util/FolderObserver.java b/src/main/java/com/nutomic/syncthingandroid/util/FolderObserver.java index 048fa987..38eef138 100644 --- a/src/main/java/com/nutomic/syncthingandroid/util/FolderObserver.java +++ b/src/main/java/com/nutomic/syncthingandroid/util/FolderObserver.java @@ -88,7 +88,9 @@ public class FolderObserver extends FileObserver { case MOVED_TO: // fall through case CREATE: - mChilds.add(new FolderObserver(mListener, mFolder, path)); + if (new File(mPath, path).isDirectory()) { + mChilds.add(new FolderObserver(mListener, mFolder, path)); + } // fall through default: mListener.onFolderFileChange(mFolder.ID, new File(mPath, path).getPath());