Browse Source

Fix NPE in Favorites when file has no local storage path

Fixes #4578

Signed-off-by: Chris Narkiewicz <hello@ezaquarii.com>
Chris Narkiewicz 5 years ago
parent
commit
88113c02df

+ 4 - 3
src/main/java/com/owncloud/android/ui/adapter/OCFileListAdapter.java

@@ -429,9 +429,10 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
                     itemViewHolder.sharedAvatars.removeAllViews();
                 }
 
-                if (onlyOnDevice) {
-                    File localFile = new File(file.getStoragePath());
-
+                // npe fix: looks like file without local storage path somehow get here
+                final String storagePath = file.getStoragePath();
+                if (onlyOnDevice && storagePath != null) {
+                    File localFile = new File(storagePath);
                     long localSize;
                     if (localFile.isDirectory()) {
                         localSize = FileStorageUtils.getFolderSize(localFile);