Skip to content
This repository
Browse code

fix plugin updating by activating manual flush mode during plugin update

  • Loading branch information...
commit 9cddd400e254375ddc83b2f22fa2559ec2ed7ccc 1 parent d6028d2
graemerocher authored November 30, 2012
28  grails-app/services/org/grails/plugin/PluginUpdateService.groovy
@@ -54,14 +54,23 @@ class PluginUpdateService implements ApplicationListener<PluginUpdateEvent> {
54 54
         // existing one. Since we already have the version, we can deal
55 55
         // with that too.
56 56
         def plugin = fetchOrCreatePluginInstance(event.name, event.version)
57  
-        pluginUpdater.updatePlugin(plugin)
58  
-        pluginService.savePlugin plugin, true
59  
-        pluginUpdater.saveRelease()
  57
+        Plugin.withSession { session ->
  58
+            try {
  59
+                session.flushMode = org.hibernate.FlushMode.MANUAL
  60
+                pluginUpdater.updatePlugin(plugin)
  61
+                pluginService.savePlugin plugin, true
  62
+                pluginUpdater.saveRelease()
  63
+
  64
+                if (pluginUpdater.newVersion && !pluginUpdater.snapshot) {
  65
+                    announceRelease plugin
  66
+                }
  67
+                else log.info "Not a new plugin release - won't tweet"
60 68
 
61  
-        if (pluginUpdater.newVersion && !pluginUpdater.snapshot) {
62  
-            announceRelease plugin
  69
+            }
  70
+            finally {
  71
+                session.flushMode = org.hibernate.FlushMode.AUTO
  72
+            }
63 73
         }
64  
-        else log.info "Not a new plugin release - won't tweet"
65 74
 
66 75
         // The master plugin list will need regenerating.
67 76
         cacheService?.removePluginList()
@@ -255,7 +264,12 @@ class PluginUpdater {
255 264
         pr.save(failOnError: true, flush:true)
256 265
 
257 266
         // Clear out associated pending releases that were created on publish.
258  
-        PendingRelease.deleteAll(pendingReleases)
  267
+        PluginRelease.withSession { session ->
  268
+            session.flushMode = org.hibernate.FlushMode.AUTO
  269
+            PendingRelease.deleteAll(pendingReleases)
  270
+            session.flushMode = org.hibernate.FlushMode.MANUAL
  271
+        }
  272
+        
259 273
     }
260 274
 
261 275
     /**

0 notes on commit 9cddd40

Please sign in to comment.
Something went wrong with that request. Please try again.