]> source.dussan.org Git - gitblit.git/commitdiff
Fixed NPE when recursively calculating a folder size with a named pipe
authorJames Moger <james.moger@gitblit.com>
Mon, 7 Jan 2013 13:10:00 +0000 (08:10 -0500)
committerJames Moger <james.moger@gitblit.com>
Mon, 7 Jan 2013 13:10:00 +0000 (08:10 -0500)
docs/04_releases.mkd
src/com/gitblit/utils/FileUtils.java

index eee191734389153d09fe33ef4572a4293b66742b..26cbd08b75e35cf9024b3e27aa15595fc321b2ca 100644 (file)
@@ -6,6 +6,7 @@
 \r
 #### fixes\r
 \r
+- Fixed nullpointer on recursively calculating folder sizes when there is a named pipe in the hierarchy\r
 - Fixed nullpointer on creating a repository with mixed case (issue 185)\r
 - Fixed nullpointer when using web.allowForking = true && git.cacheRepositoryList = false (issue 182)\r
 - Build project models from the repository model cache, when possible, to reduce page load time (issue 172)\r
index 0b8aeb4ade1caf5c4e5aa1e975e059851f8911b2..083486709d82bcc47b62275cb24ebc0f8e3c6724 100644 (file)
@@ -176,19 +176,17 @@ public class FileUtils {
        public static long folderSize(File directory) {\r
                if (directory == null || !directory.exists()) {\r
                        return -1;\r
-               }\r
-               if (directory.isFile()) {\r
-                       return directory.length();\r
-               }\r
-               long length = 0;\r
-               for (File file : directory.listFiles()) {\r
-                       if (file.isFile()) {\r
-                               length += file.length();\r
-                       } else {\r
+               }               \r
+               if (directory.isDirectory()) {\r
+                       long length = 0;\r
+                       for (File file : directory.listFiles()) {\r
                                length += folderSize(file);\r
                        }\r
+                       return length;\r
+               } else if (directory.isFile()) {\r
+                       return directory.length();\r
                }\r
-               return length;\r
+               return 0;\r
        }\r
 \r
        /**\r