]> source.dussan.org Git - gitblit.git/commitdiff
Fixed duplicate entries in repository cache (issue 140)
authorJames Moger <james.moger@gitblit.com>
Thu, 4 Oct 2012 12:04:49 +0000 (08:04 -0400)
committerJames Moger <james.moger@gitblit.com>
Thu, 4 Oct 2012 12:04:49 +0000 (08:04 -0400)
docs/04_releases.mkd
src/com/gitblit/GitBlit.java

index 30582d53e8263a7222f369b6f1a4e4970c31f9c0..ffd56ddcbc596b64d1f0b9896e0c7fbb590fa9cf 100644 (file)
@@ -11,6 +11,7 @@ If you are updating from an earlier release AND you have indexed branches with t
 \r
 #### fixes\r
 \r
+- Fixed duplicate entries in repository cache (issue 140)\r
 - Fixed connection leak in LDAPUserService (issue 139)\r
 - Fixed bug in commit page where changes to a submodule threw a null pointer exception (issue 132)\r
 - Fixed bug in the diff view for filenames that have non-ASCII characters (issue 128)\r
index 634896435e86cf6a2515da6f638b779a24d0d316..b14adc97df2c651d89c73b0aa7e8473c164cfb97 100644 (file)
@@ -746,17 +746,17 @@ public class GitBlit implements ServletContextListener {
         * Adds the repository to the list of cached repositories if Gitblit is\r
         * configured to cache the repository list.\r
         * \r
-        * @param name\r
+        * @param model\r
         */\r
-       private void addToCachedRepositoryList(String name, RepositoryModel model) {\r
+       private void addToCachedRepositoryList(RepositoryModel model) {\r
                if (settings.getBoolean(Keys.git.cacheRepositoryList, true)) {\r
-                       repositoryListCache.put(name, model);\r
+                       repositoryListCache.put(model.name, model);\r
                        \r
                        // update the fork origin repository with this repository clone\r
                        if (!StringUtils.isEmpty(model.originRepository)) {\r
                                if (repositoryListCache.containsKey(model.originRepository)) {\r
                                        RepositoryModel origin = repositoryListCache.get(model.originRepository);\r
-                                       origin.addFork(name);\r
+                                       origin.addFork(model.name);\r
                                }\r
                        }\r
                }\r
@@ -1001,7 +1001,7 @@ public class GitBlit implements ServletContextListener {
                        if (model == null) {\r
                                return null;\r
                        }\r
-                       addToCachedRepositoryList(repositoryName, model);\r
+                       addToCachedRepositoryList(model);\r
                        return model;\r
                }\r
                \r
@@ -1023,7 +1023,7 @@ public class GitBlit implements ServletContextListener {
                        logger.info(MessageFormat.format("Config for \"{0}\" has changed. Reloading model and updating cache.", repositoryName));\r
                        model = loadRepositoryModel(repositoryName);\r
                        removeFromCachedRepositoryList(repositoryName);\r
-                       addToCachedRepositoryList(repositoryName, model);\r
+                       addToCachedRepositoryList(model);\r
                } else {\r
                        // update a few repository parameters \r
                        if (!model.hasCommits) {\r
@@ -1236,10 +1236,15 @@ public class GitBlit implements ServletContextListener {
                        return null;\r
                }\r
                RepositoryModel model = new RepositoryModel();\r
-               model.name = repositoryName;\r
+               model.isBare = r.isBare();\r
+               File basePath = getFileOrFolder(Keys.git.repositoriesFolder, "git");\r
+               if (model.isBare) {\r
+                       model.name = com.gitblit.utils.FileUtils.getRelativePath(basePath, r.getDirectory());\r
+               } else {\r
+                       model.name = com.gitblit.utils.FileUtils.getRelativePath(basePath, r.getDirectory().getParentFile());\r
+               }\r
                model.hasCommits = JGitUtils.hasCommits(r);\r
                model.lastChange = JGitUtils.getLastChange(r);\r
-               model.isBare = r.isBare();\r
                if (repositoryName.indexOf('/') == -1) {\r
                        model.projectPath = "";\r
                } else {\r
@@ -1670,7 +1675,7 @@ public class GitBlit implements ServletContextListener {
                // update repository cache\r
                removeFromCachedRepositoryList(repositoryName);\r
                // model will actually be replaced on next load because config is stale\r
-               addToCachedRepositoryList(repository.name, repository);\r
+               addToCachedRepositoryList(repository);\r
        }\r
        \r
        /**\r
@@ -2678,7 +2683,7 @@ public class GitBlit implements ServletContextListener {
                }\r
 \r
                // add this clone to the cached model\r
-               addToCachedRepositoryList(cloneModel.name, cloneModel);\r
+               addToCachedRepositoryList(cloneModel);\r
                return cloneModel;\r
        }\r
 }\r