]> source.dussan.org Git - gitblit.git/commitdiff
Calculate repository sizes in Gitblit instead of the page.
authorJames Moger <james.moger@gitblit.com>
Sun, 2 Oct 2011 20:54:07 +0000 (16:54 -0400)
committerJames Moger <james.moger@gitblit.com>
Sun, 2 Oct 2011 20:54:07 +0000 (16:54 -0400)
src/com/gitblit/GitBlit.java
src/com/gitblit/wicket/panels/RepositoriesPanel.java

index 73ec29e01538e515e3c892f4227ccaba6a3dee87..1727038cff194bca4332c04c92118fe71c07ce4c 100644 (file)
@@ -62,6 +62,7 @@ import com.gitblit.models.FederationProposal;
 import com.gitblit.models.FederationSet;\r
 import com.gitblit.models.RepositoryModel;\r
 import com.gitblit.models.UserModel;\r
+import com.gitblit.utils.ByteFormat;\r
 import com.gitblit.utils.FederationUtils;\r
 import com.gitblit.utils.JGitUtils;\r
 import com.gitblit.utils.JsonUtils;\r
@@ -530,6 +531,10 @@ public class GitBlit implements ServletContextListener {
                        model.origin = config.getString("remote", "origin", "url");\r
                }\r
                r.close();\r
+               if (getBoolean(Keys.web.showRepositorySizes, true)) {\r
+                       ByteFormat byteFormat = new ByteFormat();\r
+                       model.size = byteFormat.format(calculateSize(model));                   \r
+               }\r
                return model;\r
        }\r
 \r
index 63b512c2750db4923cadaba9ee1754ed6fbe44f0..709ad82325fbb0c4d5dce6947d093bc54250f872 100644 (file)
@@ -47,7 +47,6 @@ import com.gitblit.Keys;
 import com.gitblit.SyndicationServlet;\r
 import com.gitblit.models.RepositoryModel;\r
 import com.gitblit.models.UserModel;\r
-import com.gitblit.utils.ByteFormat;\r
 import com.gitblit.utils.StringUtils;\r
 import com.gitblit.utils.TimeUtils;\r
 import com.gitblit.wicket.GitBlitWebSession;\r
@@ -71,12 +70,6 @@ public class RepositoriesPanel extends BasePanel {
                if (models == null) {\r
                        linksActive = true;\r
                        models = GitBlit.self().getRepositoryModels(user);\r
-                       final ByteFormat byteFormat = new ByteFormat();\r
-                       if (showSize) {\r
-                               for (RepositoryModel model : models) {\r
-                                       model.size = byteFormat.format(GitBlit.self().calculateSize(model));\r
-                               }\r
-                       }\r
                } else {\r
                        // disable links if the repositories are already provided\r
                        // the repositories are most likely from a proposal\r
@@ -125,7 +118,7 @@ public class RepositoriesPanel extends BasePanel {
                } else {\r
                        dp = new SortableRepositoriesProvider(models);\r
                }\r
-               \r
+\r
                final String baseUrl = WicketUtils.getGitblitURL(getRequest());\r
 \r
                DataView<RepositoryModel> dataView = new DataView<RepositoryModel>("row", dp) {\r
@@ -163,11 +156,7 @@ public class RepositoriesPanel extends BasePanel {
 \r
                                if (entry.hasCommits) {\r
                                        // Existing repository\r
-                                       if (showSize) {\r
-                                               row.add(new Label("repositorySize", entry.size));\r
-                                       } else {\r
-                                               row.add(new Label("repositorySize").setVisible(false));\r
-                                       }\r
+                                       row.add(new Label("repositorySize", entry.size).setVisible(showSize));\r
                                } else {\r
                                        // New repository\r
                                        row.add(new Label("repositorySize", "<span class='empty'>(empty)</span>")\r