Permalink
Browse files

fix plugin updating by activating manual flush mode during plugin update

  • Loading branch information...
graemerocher committed Nov 30, 2012
1 parent d6028d2 commit 9cddd400e254375ddc83b2f22fa2559ec2ed7ccc
Showing with 21 additions and 7 deletions.
  1. +21 −7 grails-app/services/org/grails/plugin/PluginUpdateService.groovy
@@ -54,14 +54,23 @@ class PluginUpdateService implements ApplicationListener<PluginUpdateEvent> {
// existing one. Since we already have the version, we can deal
// with that too.
def plugin = fetchOrCreatePluginInstance(event.name, event.version)
- pluginUpdater.updatePlugin(plugin)
- pluginService.savePlugin plugin, true
- pluginUpdater.saveRelease()
+ Plugin.withSession { session ->
+ try {
+ session.flushMode = org.hibernate.FlushMode.MANUAL
+ pluginUpdater.updatePlugin(plugin)
+ pluginService.savePlugin plugin, true
+ pluginUpdater.saveRelease()
+
+ if (pluginUpdater.newVersion && !pluginUpdater.snapshot) {
+ announceRelease plugin
+ }
+ else log.info "Not a new plugin release - won't tweet"
- if (pluginUpdater.newVersion && !pluginUpdater.snapshot) {
- announceRelease plugin
+ }
+ finally {
+ session.flushMode = org.hibernate.FlushMode.AUTO
+ }
}
- else log.info "Not a new plugin release - won't tweet"
// The master plugin list will need regenerating.
cacheService?.removePluginList()
@@ -255,7 +264,12 @@ class PluginUpdater {
pr.save(failOnError: true, flush:true)
// Clear out associated pending releases that were created on publish.
- PendingRelease.deleteAll(pendingReleases)
+ PluginRelease.withSession { session ->
+ session.flushMode = org.hibernate.FlushMode.AUTO
+ PendingRelease.deleteAll(pendingReleases)
+ session.flushMode = org.hibernate.FlushMode.MANUAL
+ }
+
}
/**

0 comments on commit 9cddd40

Please sign in to comment.