removes the test suspendable model factory code

This commit is contained in:
Shannon
2019-09-16 16:59:57 +10:00
parent bc40216eca
commit 47d3af9bb3
6 changed files with 6 additions and 103 deletions

View File

@@ -28,15 +28,13 @@ namespace Umbraco.Core.Packaging
private readonly IDataTypeService _dataTypeService; private readonly IDataTypeService _dataTypeService;
private readonly PropertyEditorCollection _propertyEditors; private readonly PropertyEditorCollection _propertyEditors;
private readonly IScopeProvider _scopeProvider; private readonly IScopeProvider _scopeProvider;
private readonly IPublishedModelFactory _publishedModelFactory;
private readonly IEntityService _entityService; private readonly IEntityService _entityService;
private readonly IContentTypeService _contentTypeService; private readonly IContentTypeService _contentTypeService;
private readonly IContentService _contentService; private readonly IContentService _contentService;
public PackageDataInstallation(ILogger logger, IFileService fileService, IMacroService macroService, ILocalizationService localizationService, public PackageDataInstallation(ILogger logger, IFileService fileService, IMacroService macroService, ILocalizationService localizationService,
IDataTypeService dataTypeService, IEntityService entityService, IContentTypeService contentTypeService, IDataTypeService dataTypeService, IEntityService entityService, IContentTypeService contentTypeService,
IContentService contentService, PropertyEditorCollection propertyEditors, IScopeProvider scopeProvider, IContentService contentService, PropertyEditorCollection propertyEditors, IScopeProvider scopeProvider)
IPublishedModelFactory publishedModelFactory)
{ {
_logger = logger; _logger = logger;
_fileService = fileService; _fileService = fileService;
@@ -45,7 +43,6 @@ namespace Umbraco.Core.Packaging
_dataTypeService = dataTypeService; _dataTypeService = dataTypeService;
_propertyEditors = propertyEditors; _propertyEditors = propertyEditors;
_scopeProvider = scopeProvider; _scopeProvider = scopeProvider;
_publishedModelFactory = publishedModelFactory;
_entityService = entityService; _entityService = entityService;
_contentTypeService = contentTypeService; _contentTypeService = contentTypeService;
_contentService = contentService; _contentService = contentService;

View File

@@ -28,17 +28,9 @@ namespace Umbraco.Core
{ {
lock (liveFactory.SyncRoot) lock (liveFactory.SyncRoot)
{ {
//if (_suspend != null) //Call refresh on the live factory to re-compile the models
//{ liveFactory.Refresh();
// //if we are currently suspended, queue the action action();
// _suspend.Queue(action);
//}
//else
//{
//Call refresh on the live factory to re-compile the models
liveFactory.Refresh();
action();
//}
} }
} }
else else
@@ -103,85 +95,5 @@ namespace Umbraco.Core
private static volatile bool _refresh = false; private static volatile bool _refresh = false;
//public static IDisposable SuspendSafeLiveFactory(this IPublishedModelFactory factory)
//{
// if (factory is ILivePublishedModelFactory liveFactory)
// {
// lock (liveFactory.SyncRoot)
// {
// if (_suspend == null)
// {
// _suspend = new SuspendSafeLiveFactory(
// factory,
// () => _suspend = null); //reset when it's done
// }
// return _suspend;
// }
// }
// else
// {
// return new SuspendSafeLiveFactory(factory); //returns a noop version of IDisposable, this won't actually do anything
// }
//}
//private static SuspendSafeLiveFactory _suspend;
}
internal class SuspendSafeLiveFactory : IDisposable
{
private readonly IPublishedModelFactory _factory;
private readonly Action _reset;
private readonly List<Action> _actions = new List<Action>();
public SuspendSafeLiveFactory(IPublishedModelFactory factory, Action reset = null)
{
_factory = factory;
_reset = reset;
}
/// <summary>
/// Queue an action to execute on disposal after rebuild
/// </summary>
/// <param name="action"></param>
public void Queue(Action action)
{
_actions.Add(action);
}
#region IDisposable Support
private bool disposedValue = false; // To detect redundant calls
protected virtual void Dispose(bool disposing)
{
if (!disposedValue)
{
if (disposing)
{
if (_factory is ILivePublishedModelFactory liveFactory)
{
lock (liveFactory.SyncRoot)
{
//Call refresh on the live factory to re-compile the models
liveFactory.Refresh();
//then we need to call all queued actions
foreach(var action in _actions)
action();
}
}
_reset?.Invoke();
}
disposedValue = true;
}
}
// This code added to correctly implement the disposable pattern.
public void Dispose()
{
// Do not change this code. Put cleanup code in Dispose(bool disposing) above.
Dispose(true);
}
#endregion
} }
} }

View File

@@ -90,7 +90,6 @@ namespace Umbraco.Web.Cache
// service of changes, else factories may try to rebuild models while // service of changes, else factories may try to rebuild models while
// we are using the database to load content into caches // we are using the database to load content into caches
//_publishedModelFactory.WithSafeLiveFactory(() =>
_publishedModelFactory.WithSafeLiveFactoryRefreshSet(() => _publishedModelFactory.WithSafeLiveFactoryRefreshSet(() =>
_publishedSnapshotService.Notify(payloads)); _publishedSnapshotService.Notify(payloads));

View File

@@ -66,7 +66,6 @@ namespace Umbraco.Web.Cache
// service of changes, else factories may try to rebuild models while // service of changes, else factories may try to rebuild models while
// we are using the database to load content into caches // we are using the database to load content into caches
//_publishedModelFactory.WithSafeLiveFactory(() =>
_publishedModelFactory.WithSafeLiveFactoryRefreshSet(() => _publishedModelFactory.WithSafeLiveFactoryRefreshSet(() =>
_publishedSnapshotService.Notify(payloads)); _publishedSnapshotService.Notify(payloads));

View File

@@ -49,7 +49,6 @@ namespace Umbraco.Web.Editors
private readonly IEntityXmlSerializer _serializer; private readonly IEntityXmlSerializer _serializer;
private readonly PropertyEditorCollection _propertyEditors; private readonly PropertyEditorCollection _propertyEditors;
private readonly IScopeProvider _scopeProvider; private readonly IScopeProvider _scopeProvider;
private readonly IPublishedModelFactory _publishedModelFactory;
public ContentTypeController(IEntityXmlSerializer serializer, public ContentTypeController(IEntityXmlSerializer serializer,
ICultureDictionaryFactory cultureDictionaryFactory, ICultureDictionaryFactory cultureDictionaryFactory,
@@ -58,13 +57,12 @@ namespace Umbraco.Web.Editors
ISqlContext sqlContext, PropertyEditorCollection propertyEditors, ISqlContext sqlContext, PropertyEditorCollection propertyEditors,
ServiceContext services, AppCaches appCaches, ServiceContext services, AppCaches appCaches,
IProfilingLogger logger, IRuntimeState runtimeState, UmbracoHelper umbracoHelper, IProfilingLogger logger, IRuntimeState runtimeState, UmbracoHelper umbracoHelper,
IScopeProvider scopeProvider, IPublishedModelFactory publishedModelFactory) IScopeProvider scopeProvider)
: base(cultureDictionaryFactory, globalSettings, umbracoContextAccessor, sqlContext, services, appCaches, logger, runtimeState, umbracoHelper) : base(cultureDictionaryFactory, globalSettings, umbracoContextAccessor, sqlContext, services, appCaches, logger, runtimeState, umbracoHelper)
{ {
_serializer = serializer; _serializer = serializer;
_propertyEditors = propertyEditors; _propertyEditors = propertyEditors;
_scopeProvider = scopeProvider; _scopeProvider = scopeProvider;
_publishedModelFactory = publishedModelFactory;
} }
public int GetCount() public int GetCount()
@@ -527,7 +525,7 @@ namespace Umbraco.Web.Editors
} }
var dataInstaller = new PackageDataInstallation(Logger, Services.FileService, Services.MacroService, Services.LocalizationService, var dataInstaller = new PackageDataInstallation(Logger, Services.FileService, Services.MacroService, Services.LocalizationService,
Services.DataTypeService, Services.EntityService, Services.ContentTypeService, Services.ContentService, _propertyEditors, _scopeProvider, _publishedModelFactory); Services.DataTypeService, Services.EntityService, Services.ContentTypeService, Services.ContentService, _propertyEditors, _scopeProvider);
var xd = new XmlDocument {XmlResolver = null}; var xd = new XmlDocument {XmlResolver = null};
xd.Load(filePath); xd.Load(filePath);

View File

@@ -790,8 +790,6 @@ namespace Umbraco.Web.PublishedCache.NuCache
Notify<IContentType>(_contentStore, payloads, RefreshContentTypesLocked); Notify<IContentType>(_contentStore, payloads, RefreshContentTypesLocked);
Notify<IMediaType>(_mediaStore, payloads, RefreshMediaTypesLocked); Notify<IMediaType>(_mediaStore, payloads, RefreshMediaTypesLocked);
//TODO: I don't think this is necessary with the changes to nucache now that calls to `CreateModel` are lazy?
// but I may be dreaming here, if i remove this call and save a content type, then the cache doesn't render a lot of the content. hrm.
if (_publishedModelFactory.IsLiveFactory()) if (_publishedModelFactory.IsLiveFactory())
{ {
//In the case of Pure Live - we actually need to refresh all of the content and the media //In the case of Pure Live - we actually need to refresh all of the content and the media