]> source.dussan.org Git - gitblit.git/commitdiff
Log calculation time of repository sizes. (issue 27)
authorJames Moger <james.moger@gitblit.com>
Fri, 21 Oct 2011 12:32:27 +0000 (08:32 -0400)
committerJames Moger <james.moger@gitblit.com>
Fri, 21 Oct 2011 12:32:27 +0000 (08:32 -0400)
Also added a per-repository skip calculation flag.

src/com/gitblit/GitBlit.java
src/com/gitblit/client/EditRepositoryDialog.java
src/com/gitblit/models/RepositoryModel.java
src/com/gitblit/wicket/GitBlitWebApp.properties
src/com/gitblit/wicket/pages/EditRepositoryPage.html
src/com/gitblit/wicket/pages/EditRepositoryPage.java

index 1727038cff194bca4332c04c92118fe71c07ce4c..50eeb9ebddc20b122c2889c9d30281f30f6d0281 100644 (file)
@@ -470,6 +470,20 @@ public class GitBlit implements ServletContextListener {
                                repositories.add(model);\r
                        }\r
                }\r
+               if (getBoolean(Keys.web.showRepositorySizes, true)) {\r
+                       int repoCount = 0;\r
+                       long startTime = System.currentTimeMillis();\r
+                       ByteFormat byteFormat = new ByteFormat();\r
+                       for (RepositoryModel model : repositories) {\r
+                               if (!model.skipSizeCalculation) {\r
+                                       repoCount++;\r
+                                       model.size = byteFormat.format(calculateSize(model));\r
+                               }\r
+                       }\r
+                       long duration = System.currentTimeMillis() - startTime;\r
+                       logger.info(MessageFormat.format("{0} repository sizes calculated in {1} msecs",\r
+                                       repoCount, duration));\r
+               }\r
                return repositories;\r
        }\r
 \r
@@ -523,6 +537,7 @@ public class GitBlit implements ServletContextListener {
                        model.showRemoteBranches = getConfig(config, "showRemoteBranches", false);\r
                        model.isFrozen = getConfig(config, "isFrozen", false);\r
                        model.showReadme = getConfig(config, "showReadme", false);\r
+                       model.skipSizeCalculation = getConfig(config, "skipSizeCalculation", false);\r
                        model.federationStrategy = FederationStrategy.fromName(getConfig(config,\r
                                        "federationStrategy", null));\r
                        model.federationSets = new ArrayList<String>(Arrays.asList(config.getStringList(\r
@@ -531,10 +546,6 @@ 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
@@ -707,6 +718,7 @@ public class GitBlit implements ServletContextListener {
                config.setBoolean("gitblit", null, "showRemoteBranches", repository.showRemoteBranches);\r
                config.setBoolean("gitblit", null, "isFrozen", repository.isFrozen);\r
                config.setBoolean("gitblit", null, "showReadme", repository.showReadme);\r
+               config.setBoolean("gitblit", null, "skipSizeCalculation", repository.skipSizeCalculation);\r
                config.setStringList("gitblit", null, "federationSets", repository.federationSets);\r
                config.setString("gitblit", null, "federationStrategy",\r
                                repository.federationStrategy.name());\r
index 9fc8e5c931ae6bb9bdd18a11e20789516494bf42..93330cd1c44394250a4bab5f5bbb64c24c17b48f 100644 (file)
@@ -81,6 +81,8 @@ public class EditRepositoryDialog extends JDialog {
 \r
        private JCheckBox showReadme;\r
 \r
+       private JCheckBox skipSizeCalculation;\r
+\r
        private JCheckBox isFrozen;\r
 \r
        private JComboBox accessRestriction;\r
@@ -143,6 +145,8 @@ public class EditRepositoryDialog extends JDialog {
                                anRepository.showRemoteBranches);\r
                showReadme = new JCheckBox(Translation.get("gb.showReadmeDescription"),\r
                                anRepository.showReadme);\r
+               skipSizeCalculation = new JCheckBox(Translation.get("gb.skipSizeCalculationDescription"),\r
+                               anRepository.skipSizeCalculation);\r
                isFrozen = new JCheckBox(Translation.get("gb.isFrozenDescription"), anRepository.isFrozen);\r
 \r
                accessRestriction = new JComboBox(AccessRestrictionType.values());\r
@@ -171,6 +175,7 @@ public class EditRepositoryDialog extends JDialog {
                fieldsPanel\r
                                .add(newFieldPanel(Translation.get("gb.showRemoteBranches"), showRemoteBranches));\r
                fieldsPanel.add(newFieldPanel(Translation.get("gb.showReadme"), showReadme));\r
+               fieldsPanel.add(newFieldPanel(Translation.get("gb.skipSizeCalculation"), skipSizeCalculation));\r
                fieldsPanel.add(newFieldPanel(Translation.get("gb.isFrozen"), isFrozen));\r
 \r
                usersPalette = new JPalette<String>();\r
@@ -307,6 +312,7 @@ public class EditRepositoryDialog extends JDialog {
                repository.useDocs = useDocs.isSelected();\r
                repository.showRemoteBranches = showRemoteBranches.isSelected();\r
                repository.showReadme = showReadme.isSelected();\r
+               repository.skipSizeCalculation = skipSizeCalculation.isSelected();\r
                repository.isFrozen = isFrozen.isSelected();\r
 \r
                repository.accessRestriction = (AccessRestrictionType) accessRestriction.getSelectedItem();\r
index d70866fbbfd1391c13d3afc0da1066151e2b4fca..6909f1a4f0d3baf79e702010c721e34e968ba603 100644 (file)
@@ -50,6 +50,7 @@ public class RepositoryModel implements Serializable, Comparable<RepositoryModel
        public FederationStrategy federationStrategy;\r
        public List<String> federationSets;\r
        public boolean isFederated;\r
+       public boolean skipSizeCalculation;\r
        public String frequency;\r
        public String origin;\r
        public String size;\r
index 109f933a82de7ee190ebc2295e4198850500d3ce..6d713e3fadaa9ac0f357fe76cd08962ee6a1dce3 100644 (file)
@@ -158,4 +158,6 @@ gb.starting = starting
 gb.general = general\r
 gb.settings = settings\r
 gb.manage = manage\r
-gb.lastLogin = last login
\ No newline at end of file
+gb.lastLogin = last login\r
+gb.skipSizeCalculation = skip size calculation\r
+gb.skipSizeCalculationDescription = do not calculate the repository size
\ No newline at end of file
index 7f09f75c363f20f11c866d2e3e64c1dc28c28057..cb2168706bbdfc4446d61c5523346612771ef705 100644 (file)
                                <tr><th><wicket:message key="gb.enableDocs"></wicket:message></th><td class="edit"><input type="checkbox" wicket:id="useDocs" tabindex="6" /> &nbsp;<i><wicket:message key="gb.useDocsDescription"></wicket:message></i></td></tr>\r
                                <tr><th><wicket:message key="gb.showRemoteBranches"></wicket:message></th><td class="edit"><input type="checkbox" wicket:id="showRemoteBranches" tabindex="7" /> &nbsp;<i><wicket:message key="gb.showRemoteBranchesDescription"></wicket:message></i></td></tr>\r
                                <tr><th><wicket:message key="gb.showReadme"></wicket:message></th><td class="edit"><input type="checkbox" wicket:id="showReadme" tabindex="8" /> &nbsp;<i><wicket:message key="gb.showReadmeDescription"></wicket:message></i></td></tr>\r
-                               <tr><th><wicket:message key="gb.isFrozen"></wicket:message></th><td class="edit"><input type="checkbox" wicket:id="isFrozen" tabindex="9" /> &nbsp;<i><wicket:message key="gb.isFrozenDescription"></wicket:message></i></td></tr>\r
+                               <tr><th><wicket:message key="gb.skipSizeCalculation"></wicket:message></th><td class="edit"><input type="checkbox" wicket:id="skipSizeCalculation" tabindex="9" /> &nbsp;<i><wicket:message key="gb.skipSizeCalculationDescription"></wicket:message></i></td></tr>\r
+                               <tr><th><wicket:message key="gb.isFrozen"></wicket:message></th><td class="edit"><input type="checkbox" wicket:id="isFrozen" tabindex="10" /> &nbsp;<i><wicket:message key="gb.isFrozenDescription"></wicket:message></i></td></tr>\r
                                <tr><td colspan="2"><hr></hr></td></tr>\r
-                               <tr><th><wicket:message key="gb.accessRestriction"></wicket:message></th><td class="edit"><select class="span6" wicket:id="accessRestriction" tabindex="10" /></td></tr>                                \r
+                               <tr><th><wicket:message key="gb.accessRestriction"></wicket:message></th><td class="edit"><select class="span6" wicket:id="accessRestriction" tabindex="11" /></td></tr>                                \r
                                <tr><th style="vertical-align: top;"><wicket:message key="gb.permittedUsers"></wicket:message></th><td style="padding:2px;"><span wicket:id="users"></span></td></tr>\r
                                <tr><td colspan="2"><hr></hr></td></tr>         \r
-                               <tr><th><wicket:message key="gb.federationStrategy"></wicket:message></th><td class="edit"><select class="span6" wicket:id="federationStrategy" tabindex="11" /></td></tr>\r
+                               <tr><th><wicket:message key="gb.federationStrategy"></wicket:message></th><td class="edit"><select class="span6" wicket:id="federationStrategy" tabindex="12" /></td></tr>\r
                                <tr><th style="vertical-align: top;"><wicket:message key="gb.federationSets"></wicket:message></th><td style="padding:2px;"><span wicket:id="federationSets"></span></td></tr>\r
-                               <tr><th></th><td class="editButton"><input class="btn" type="submit" value="Cancel" wicket:message="value:gb.cancel" wicket:id="cancel" tabindex="12" /> &nbsp; <input class="btn primary" type="submit" value="Save" wicket:message="value:gb.save" wicket:id="save" tabindex="13" /> </td></tr>\r
+                               <tr><th></th><td class="editButton"><input class="btn" type="submit" value="Cancel" wicket:message="value:gb.cancel" wicket:id="cancel" tabindex="13" /> &nbsp; <input class="btn primary" type="submit" value="Save" wicket:message="value:gb.save" wicket:id="save" tabindex="14" /> </td></tr>\r
                        </tbody>\r
                </table>\r
        </form> \r
index 4212a85f8979f8ce80018ee4b7eede6a8b43a9a0..ee79d500d3abfc5c03e30f8fe81f495fd5b381bc 100644 (file)
@@ -212,6 +212,7 @@ public class EditRepositoryPage extends RootSubPage {
                form.add(new CheckBox("useDocs"));\r
                form.add(new CheckBox("showRemoteBranches"));\r
                form.add(new CheckBox("showReadme"));\r
+               form.add(new CheckBox("skipSizeCalculation"));\r
                form.add(usersPalette);\r
                form.add(federationSetsPalette);\r
 \r