From 8390c2d368ffc0dc33c66a38103de0f7c9bf929c Mon Sep 17 00:00:00 2001 From: ethan-sparkdevnetwork Date: Fri, 21 Jan 2022 15:49:10 -0700 Subject: [PATCH] - Added a check to the Rock Update block to ensure the block compile and less compile are not running when the update button is pushed. --- RockWeb/App_Code/Global.asax.cs | 15 +++++++++++---- RockWeb/Blocks/Core/RockUpdate.ascx | 6 ++++++ RockWeb/Blocks/Core/RockUpdate.ascx.cs | 19 +++++++++++++++++++ 3 files changed, 36 insertions(+), 4 deletions(-) diff --git a/RockWeb/App_Code/Global.asax.cs b/RockWeb/App_Code/Global.asax.cs index cec7b4af92d..57665382786 100644 --- a/RockWeb/App_Code/Global.asax.cs +++ b/RockWeb/App_Code/Global.asax.cs @@ -56,6 +56,9 @@ public class Global : System.Web.HttpApplication // cache callback object private static CacheItemRemovedCallback _onCacheRemove = null; + public static Thread CompileThemesThread = null; + public static Thread BlockTypeCompilationThread = null; + #endregion #region Asp.Net Events @@ -227,7 +230,7 @@ protected void Application_Start( object sender, EventArgs e ) private static void StartCompileThemesThread() { // compile less files - new Thread( () => + CompileThemesThread = new Thread( () => { /* Set to background thread so that this thread doesn't prevent Rock from shutting down. */ var stopwatchCompileLess = Stopwatch.StartNew(); @@ -248,7 +251,9 @@ private static void StartCompileThemesThread() System.Diagnostics.Debug.WriteLine( "RockTheme.CompileAll messages: " + messages ); } } - } ).Start(); + } ); + + CompileThemesThread.Start(); } /// @@ -272,7 +277,7 @@ private static void StartWorkflowActionUpdateAttributesThread() /// private static void StartBlockTypeCompilationThread() { - new Thread( () => + BlockTypeCompilationThread = new Thread( () => { // Set to background thread so that this thread doesn't prevent Rock from shutting down. Thread.CurrentThread.IsBackground = true; @@ -292,7 +297,9 @@ private static void StartBlockTypeCompilationThread() BlockTypeService.VerifyBlockTypeInstanceProperties( allUsedBlockTypeIds, _threadCancellationTokenSource.Token ); Debug.WriteLine( string.Format( "[{0,5:#} seconds] All block types Compiled", stopwatchCompileBlockTypes.Elapsed.TotalSeconds ) ); - } ).Start(); + } ); + + BlockTypeCompilationThread.Start(); } /// diff --git a/RockWeb/Blocks/Core/RockUpdate.ascx b/RockWeb/Blocks/Core/RockUpdate.ascx index c24d5b99c70..27056f0b468 100644 --- a/RockWeb/Blocks/Core/RockUpdate.ascx +++ b/RockWeb/Blocks/Core/RockUpdate.ascx @@ -32,6 +32,12 @@ You will need to upgrade your database in order to proceed with that update.

+ +

Background Process Running

+

+ Rock is running one or more processes that may lock files that will be updated. These will be checked again after clicking the update button. If this message appears again wait a minute and try again. +

+

Everything Is Shipshape

diff --git a/RockWeb/Blocks/Core/RockUpdate.ascx.cs b/RockWeb/Blocks/Core/RockUpdate.ascx.cs index 5377bc24635..e9542cad0ed 100644 --- a/RockWeb/Blocks/Core/RockUpdate.ascx.cs +++ b/RockWeb/Blocks/Core/RockUpdate.ascx.cs @@ -94,6 +94,17 @@ protected override void OnLoad( EventArgs e ) nbRepoWarning.Visible = true; } + if ( Global.CompileThemesThread.IsAlive || Global.BlockTypeCompilationThread.IsAlive ) + { + // Display a warning here but don't prevent them from going forward. This will be checked again after clicking update. + nbCompileThreadsIssue.Visible = true; + } + else + { + // Hide the warning + nbCompileThreadsIssue.Visible = false; + } + DisplayRockVersion(); if ( !IsPostBack ) { @@ -472,6 +483,14 @@ private void SendStatictics( string version ) protected void mdConfirmInstall_SaveClick( object sender, EventArgs e ) { + if ( Global.CompileThemesThread.IsAlive || Global.BlockTypeCompilationThread.IsAlive ) + { + // Show message here and return + nbCompileThreadsIssue.Visible = true; + return; + } + + nbCompileThreadsIssue.Visible = false; mdConfirmInstall.Hide(); Update( hdnInstallVersion.Value ); }