From: James Moger Date: Fri, 21 Oct 2011 12:32:27 +0000 (-0400) Subject: Log calculation time of repository sizes. (issue 27) X-Git-Tag: v0.7.0~66 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=3d293a9d1194bd98beb624f1bb0b047cb4467a93;p=gitblit.git Log calculation time of repository sizes. (issue 27) Also added a per-repository skip calculation flag. --- diff --git a/src/com/gitblit/GitBlit.java b/src/com/gitblit/GitBlit.java index 1727038c..50eeb9eb 100644 --- a/src/com/gitblit/GitBlit.java +++ b/src/com/gitblit/GitBlit.java @@ -470,6 +470,20 @@ public class GitBlit implements ServletContextListener { repositories.add(model); } } + if (getBoolean(Keys.web.showRepositorySizes, true)) { + int repoCount = 0; + long startTime = System.currentTimeMillis(); + ByteFormat byteFormat = new ByteFormat(); + for (RepositoryModel model : repositories) { + if (!model.skipSizeCalculation) { + repoCount++; + model.size = byteFormat.format(calculateSize(model)); + } + } + long duration = System.currentTimeMillis() - startTime; + logger.info(MessageFormat.format("{0} repository sizes calculated in {1} msecs", + repoCount, duration)); + } return repositories; } @@ -523,6 +537,7 @@ public class GitBlit implements ServletContextListener { model.showRemoteBranches = getConfig(config, "showRemoteBranches", false); model.isFrozen = getConfig(config, "isFrozen", false); model.showReadme = getConfig(config, "showReadme", false); + model.skipSizeCalculation = getConfig(config, "skipSizeCalculation", false); model.federationStrategy = FederationStrategy.fromName(getConfig(config, "federationStrategy", null)); model.federationSets = new ArrayList(Arrays.asList(config.getStringList( @@ -531,10 +546,6 @@ 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; } @@ -707,6 +718,7 @@ public class GitBlit implements ServletContextListener { config.setBoolean("gitblit", null, "showRemoteBranches", repository.showRemoteBranches); config.setBoolean("gitblit", null, "isFrozen", repository.isFrozen); config.setBoolean("gitblit", null, "showReadme", repository.showReadme); + config.setBoolean("gitblit", null, "skipSizeCalculation", repository.skipSizeCalculation); config.setStringList("gitblit", null, "federationSets", repository.federationSets); config.setString("gitblit", null, "federationStrategy", repository.federationStrategy.name()); diff --git a/src/com/gitblit/client/EditRepositoryDialog.java b/src/com/gitblit/client/EditRepositoryDialog.java index 9fc8e5c9..93330cd1 100644 --- a/src/com/gitblit/client/EditRepositoryDialog.java +++ b/src/com/gitblit/client/EditRepositoryDialog.java @@ -81,6 +81,8 @@ public class EditRepositoryDialog extends JDialog { private JCheckBox showReadme; + private JCheckBox skipSizeCalculation; + private JCheckBox isFrozen; private JComboBox accessRestriction; @@ -143,6 +145,8 @@ public class EditRepositoryDialog extends JDialog { anRepository.showRemoteBranches); showReadme = new JCheckBox(Translation.get("gb.showReadmeDescription"), anRepository.showReadme); + skipSizeCalculation = new JCheckBox(Translation.get("gb.skipSizeCalculationDescription"), + anRepository.skipSizeCalculation); isFrozen = new JCheckBox(Translation.get("gb.isFrozenDescription"), anRepository.isFrozen); accessRestriction = new JComboBox(AccessRestrictionType.values()); @@ -171,6 +175,7 @@ public class EditRepositoryDialog extends JDialog { fieldsPanel .add(newFieldPanel(Translation.get("gb.showRemoteBranches"), showRemoteBranches)); fieldsPanel.add(newFieldPanel(Translation.get("gb.showReadme"), showReadme)); + fieldsPanel.add(newFieldPanel(Translation.get("gb.skipSizeCalculation"), skipSizeCalculation)); fieldsPanel.add(newFieldPanel(Translation.get("gb.isFrozen"), isFrozen)); usersPalette = new JPalette(); @@ -307,6 +312,7 @@ public class EditRepositoryDialog extends JDialog { repository.useDocs = useDocs.isSelected(); repository.showRemoteBranches = showRemoteBranches.isSelected(); repository.showReadme = showReadme.isSelected(); + repository.skipSizeCalculation = skipSizeCalculation.isSelected(); repository.isFrozen = isFrozen.isSelected(); repository.accessRestriction = (AccessRestrictionType) accessRestriction.getSelectedItem(); diff --git a/src/com/gitblit/models/RepositoryModel.java b/src/com/gitblit/models/RepositoryModel.java index d70866fb..6909f1a4 100644 --- a/src/com/gitblit/models/RepositoryModel.java +++ b/src/com/gitblit/models/RepositoryModel.java @@ -50,6 +50,7 @@ public class RepositoryModel implements Serializable, Comparable federationSets; public boolean isFederated; + public boolean skipSizeCalculation; public String frequency; public String origin; public String size; diff --git a/src/com/gitblit/wicket/GitBlitWebApp.properties b/src/com/gitblit/wicket/GitBlitWebApp.properties index 109f933a..6d713e3f 100644 --- a/src/com/gitblit/wicket/GitBlitWebApp.properties +++ b/src/com/gitblit/wicket/GitBlitWebApp.properties @@ -158,4 +158,6 @@ gb.starting = starting gb.general = general gb.settings = settings gb.manage = manage -gb.lastLogin = last login \ No newline at end of file +gb.lastLogin = last login +gb.skipSizeCalculation = skip size calculation +gb.skipSizeCalculationDescription = do not calculate the repository size \ No newline at end of file diff --git a/src/com/gitblit/wicket/pages/EditRepositoryPage.html b/src/com/gitblit/wicket/pages/EditRepositoryPage.html index 7f09f75c..cb216870 100644 --- a/src/com/gitblit/wicket/pages/EditRepositoryPage.html +++ b/src/com/gitblit/wicket/pages/EditRepositoryPage.html @@ -18,14 +18,15 @@       -   +   +  
-
- -   +   diff --git a/src/com/gitblit/wicket/pages/EditRepositoryPage.java b/src/com/gitblit/wicket/pages/EditRepositoryPage.java index 4212a85f..ee79d500 100644 --- a/src/com/gitblit/wicket/pages/EditRepositoryPage.java +++ b/src/com/gitblit/wicket/pages/EditRepositoryPage.java @@ -212,6 +212,7 @@ public class EditRepositoryPage extends RootSubPage { form.add(new CheckBox("useDocs")); form.add(new CheckBox("showRemoteBranches")); form.add(new CheckBox("showReadme")); + form.add(new CheckBox("skipSizeCalculation")); form.add(usersPalette); form.add(federationSetsPalette);