mirror of
https://github.com/syncthing/syncthing-android.git
synced 2024-11-26 14:21:16 +00:00
Fix possible NullPointerException in FolderObserver.
This commit is contained in:
parent
8edf8201e3
commit
e43ca2adfc
1 changed files with 9 additions and 5 deletions
|
@ -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());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue