From: James Moger Date: Sun, 2 Oct 2011 20:54:07 +0000 (-0400) Subject: Calculate repository sizes in Gitblit instead of the page. X-Git-Tag: v0.7.0~97 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=72633de4757587d7629dc42b41b8923c7c3d675f;p=gitblit.git Calculate repository sizes in Gitblit instead of the page. --- diff --git a/src/com/gitblit/GitBlit.java b/src/com/gitblit/GitBlit.java index 73ec29e0..1727038c 100644 --- a/src/com/gitblit/GitBlit.java +++ b/src/com/gitblit/GitBlit.java @@ -62,6 +62,7 @@ import com.gitblit.models.FederationProposal; import com.gitblit.models.FederationSet; import com.gitblit.models.RepositoryModel; import com.gitblit.models.UserModel; +import com.gitblit.utils.ByteFormat; import com.gitblit.utils.FederationUtils; import com.gitblit.utils.JGitUtils; import com.gitblit.utils.JsonUtils; @@ -530,6 +531,10 @@ public class GitBlit implements ServletContextListener { model.origin = config.getString("remote", "origin", "url"); } r.close(); + if (getBoolean(Keys.web.showRepositorySizes, true)) { + ByteFormat byteFormat = new ByteFormat(); + model.size = byteFormat.format(calculateSize(model)); + } return model; } diff --git a/src/com/gitblit/wicket/panels/RepositoriesPanel.java b/src/com/gitblit/wicket/panels/RepositoriesPanel.java index 63b512c2..709ad823 100644 --- a/src/com/gitblit/wicket/panels/RepositoriesPanel.java +++ b/src/com/gitblit/wicket/panels/RepositoriesPanel.java @@ -47,7 +47,6 @@ import com.gitblit.Keys; import com.gitblit.SyndicationServlet; import com.gitblit.models.RepositoryModel; import com.gitblit.models.UserModel; -import com.gitblit.utils.ByteFormat; import com.gitblit.utils.StringUtils; import com.gitblit.utils.TimeUtils; import com.gitblit.wicket.GitBlitWebSession; @@ -71,12 +70,6 @@ public class RepositoriesPanel extends BasePanel { if (models == null) { linksActive = true; models = GitBlit.self().getRepositoryModels(user); - final ByteFormat byteFormat = new ByteFormat(); - if (showSize) { - for (RepositoryModel model : models) { - model.size = byteFormat.format(GitBlit.self().calculateSize(model)); - } - } } else { // disable links if the repositories are already provided // the repositories are most likely from a proposal @@ -125,7 +118,7 @@ public class RepositoriesPanel extends BasePanel { } else { dp = new SortableRepositoriesProvider(models); } - + final String baseUrl = WicketUtils.getGitblitURL(getRequest()); DataView dataView = new DataView("row", dp) { @@ -163,11 +156,7 @@ public class RepositoriesPanel extends BasePanel { if (entry.hasCommits) { // Existing repository - if (showSize) { - row.add(new Label("repositorySize", entry.size)); - } else { - row.add(new Label("repositorySize").setVisible(false)); - } + row.add(new Label("repositorySize", entry.size).setVisible(showSize)); } else { // New repository row.add(new Label("repositorySize", "(empty)")