From 84e9519807096f2bd7c3f3603f5b451529d28db6 Mon Sep 17 00:00:00 2001 From: tobiasKaminsky Date: Thu, 15 Mar 2018 12:25:37 +0100 Subject: [PATCH] changes due to CR Signed-off-by: tobiasKaminsky --- .../android/utils/FileStorageUtils.java | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/owncloud/android/utils/FileStorageUtils.java b/src/main/java/com/owncloud/android/utils/FileStorageUtils.java index bcabf6c9d7..04f4b0368e 100644 --- a/src/main/java/com/owncloud/android/utils/FileStorageUtils.java +++ b/src/main/java/com/owncloud/android/utils/FileStorageUtils.java @@ -217,16 +217,20 @@ public class FileStorageUtils { * @return Size in bytes */ public static long getFolderSize(File dir) { - if (dir.exists() && dir.isDirectory() && dir.listFiles() != null) { - long result = 0; - for (File f : dir.listFiles()) { - if (f.isDirectory()) { - result += getFolderSize(f); - } else { - result += f.length(); + if (dir.exists() && dir.isDirectory()) { + File[] files = dir.listFiles(); + + if (files != null) { + long result = 0; + for (File f : files) { + if (f.isDirectory()) { + result += getFolderSize(f); + } else { + result += f.length(); + } } + return result; } - return result; } return 0; }