* Rename Umbraco.Core namespace to Umbraco.Cms.Core * Move extension methods in core project to Umbraco.Extensions * Move extension methods in core project to Umbraco.Extensions * Rename Umbraco.Examine namespace to Umbraco.Cms.Examine * Move examine extensions to Umbraco.Extensions namespace * Reflect changed namespaces in Builder and fix unit tests * Adjust namespace in Umbraco.ModelsBuilder.Embedded * Adjust namespace in Umbraco.Persistence.SqlCe * Adjust namespace in Umbraco.PublishedCache.NuCache * Align namespaces in Umbraco.Web.BackOffice * Align namespaces in Umbraco.Web.Common * Ensure that SqlCeSupport is still enabled after changing the namespace * Align namespaces in Umbraco.Web.Website * Align namespaces in Umbraco.Web.UI.NetCore * Align namespaces in Umbraco.Tests.Common * Align namespaces in Umbraco.Tests.UnitTests * Align namespaces in Umbraco.Tests.Integration * Fix errors caused by changed namespaces * Fix integration tests * Undo the Umbraco.Examine.Lucene namespace change This breaks integration tests on linux, since the namespace wont exists there because it's only used on windows. * Fix merge * Fix Merge
108 lines
3.4 KiB
C#
108 lines
3.4 KiB
C#
using Microsoft.Extensions.Logging;
|
|
using Umbraco.Cms.Core;
|
|
using Umbraco.Cms.Core.Cache;
|
|
using Umbraco.Core;
|
|
using Umbraco.Core.Cache;
|
|
using Umbraco.Examine;
|
|
using Umbraco.Web.Cache;
|
|
using Umbraco.Web.Search;
|
|
|
|
namespace Umbraco.Web
|
|
{
|
|
internal static class Suspendable
|
|
{
|
|
public static class PageCacheRefresher
|
|
{
|
|
private static bool _tried, _suspended;
|
|
|
|
public static bool CanRefreshDocumentCacheFromDatabase
|
|
{
|
|
get
|
|
{
|
|
// trying a full refresh
|
|
if (_suspended == false) return true;
|
|
_tried = true; // remember we tried
|
|
return false;
|
|
}
|
|
}
|
|
|
|
// trying a partial update
|
|
// ok if not suspended, or if we haven't done a full already
|
|
public static bool CanUpdateDocumentCache => _suspended == false || _tried == false;
|
|
|
|
public static void SuspendDocumentCache()
|
|
{
|
|
StaticApplicationLogging.Logger.LogInformation("Suspend document cache.");
|
|
_suspended = true;
|
|
}
|
|
|
|
public static void ResumeDocumentCache(CacheRefresherCollection cacheRefresherCollection)
|
|
{
|
|
_suspended = false;
|
|
|
|
StaticApplicationLogging.Logger.LogInformation("Resume document cache (reload:{Tried}).", _tried);
|
|
|
|
if (_tried == false) return;
|
|
_tried = false;
|
|
|
|
var pageRefresher = cacheRefresherCollection[ContentCacheRefresher.UniqueId];
|
|
pageRefresher.RefreshAll();
|
|
}
|
|
}
|
|
|
|
//This is really needed at all since the only place this is used is in ExamineComponent and that already maintains a flag of whether it suspsended or not
|
|
// AHH... but Deploy probably uses this?
|
|
public static class ExamineEvents
|
|
{
|
|
private static bool _tried, _suspended;
|
|
|
|
public static bool CanIndex
|
|
{
|
|
get
|
|
{
|
|
if (_suspended == false) return true;
|
|
_tried = true; // remember we tried
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public static void SuspendIndexers(ILogger logger)
|
|
{
|
|
logger.LogInformation("Suspend indexers.");
|
|
_suspended = true;
|
|
}
|
|
|
|
public static void ResumeIndexers(IndexRebuilder indexRebuilder, ILogger logger, BackgroundIndexRebuilder backgroundIndexRebuilder)
|
|
{
|
|
_suspended = false;
|
|
|
|
StaticApplicationLogging.Logger.LogInformation("Resume indexers (rebuild:{Tried}).", _tried);
|
|
|
|
if (_tried == false) return;
|
|
_tried = false;
|
|
|
|
backgroundIndexRebuilder.RebuildIndexes(false);
|
|
}
|
|
}
|
|
|
|
public static class ScheduledPublishing
|
|
{
|
|
private static bool _suspended;
|
|
|
|
public static bool CanRun => _suspended == false;
|
|
|
|
public static void Suspend()
|
|
{
|
|
StaticApplicationLogging.Logger.LogInformation("Suspend scheduled publishing.");
|
|
_suspended = true;
|
|
}
|
|
|
|
public static void Resume()
|
|
{
|
|
StaticApplicationLogging.Logger.LogInformation("Resume scheduled publishing.");
|
|
_suspended = false;
|
|
}
|
|
}
|
|
}
|
|
}
|