1
0
Fork 0
mirror of https://github.com/syncthing/syncthing-android.git synced 2024-11-30 00:01:19 +00:00

Fix possible NullPointerException in FolderObserver.

This commit is contained in:
Felix Ableitner 2015-03-14 11:51:02 +01:00
parent 8edf8201e3
commit e43ca2adfc

View file

@ -91,15 +91,19 @@ public class FolderObserver extends FileObserver {
if (event == 0) if (event == 0)
return; return;
File fullPath = (path != null)
? new File(mPath, path)
: new File(mPath);
switch (event) { switch (event) {
case MOVED_FROM: case MOVED_FROM:
// fall through // fall through
case DELETE_SELF: case DELETE_SELF:
// fall through // fall through
case DELETE: case DELETE:
for (FolderObserver ro : mChilds) { for (FolderObserver c : mChilds) {
if (ro.mPath.equals(path)) { if (c.mPath.equals(path)) {
mChilds.remove(ro); mChilds.remove(c);
break; break;
} }
} }
@ -107,12 +111,12 @@ public class FolderObserver extends FileObserver {
case MOVED_TO: case MOVED_TO:
// fall through // fall through
case CREATE: case CREATE:
if (new File(mPath, path).isDirectory()) { if (fullPath.isDirectory()) {
mChilds.add(new FolderObserver(mListener, mFolder, path)); mChilds.add(new FolderObserver(mListener, mFolder, path));
} }
// fall through // fall through
default: default:
mListener.onFolderFileChange(mFolder.ID, new File(mPath, path).getPath()); mListener.onFolderFileChange(mFolder.ID, fullPath.getPath());
} }
} }