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)
|
||||
return;
|
||||
|
||||
File fullPath = (path != null)
|
||||
? new File(mPath, path)
|
||||
: new File(mPath);
|
||||
|
||||
switch (event) {
|
||||
case MOVED_FROM:
|
||||
// fall through
|
||||
case DELETE_SELF:
|
||||
// fall through
|
||||
case DELETE:
|
||||
for (FolderObserver ro : mChilds) {
|
||||
if (ro.mPath.equals(path)) {
|
||||
mChilds.remove(ro);
|
||||
for (FolderObserver c : mChilds) {
|
||||
if (c.mPath.equals(path)) {
|
||||
mChilds.remove(c);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -107,12 +111,12 @@ public class FolderObserver extends FileObserver {
|
|||
case MOVED_TO:
|
||||
// fall through
|
||||
case CREATE:
|
||||
if (new File(mPath, path).isDirectory()) {
|
||||
if (fullPath.isDirectory()) {
|
||||
mChilds.add(new FolderObserver(mListener, mFolder, path));
|
||||
}
|
||||
// fall through
|
||||
default:
|
||||
mListener.onFolderFileChange(mFolder.ID, new File(mPath, path).getPath());
|
||||
mListener.onFolderFileChange(mFolder.ID, fullPath.getPath());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue