Merge pull request #10847 from umbraco/v8/bugfix/backport-fix-for-10774-into-v8
Backport fix for #10774 to v8
This commit is contained in:
@@ -347,28 +347,6 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
return path;
|
||||
}
|
||||
|
||||
private void DeleteLocalFilesForContent()
|
||||
{
|
||||
if (_isReady && _localContentDb != null)
|
||||
throw new InvalidOperationException("Cannot delete local files while the cache uses them.");
|
||||
|
||||
var path = GetLocalFilesPath();
|
||||
var localContentDbPath = Path.Combine(path, "NuCache.Content.db");
|
||||
if (File.Exists(localContentDbPath))
|
||||
File.Delete(localContentDbPath);
|
||||
}
|
||||
|
||||
private void DeleteLocalFilesForMedia()
|
||||
{
|
||||
if (_isReady && _localMediaDb != null)
|
||||
throw new InvalidOperationException("Cannot delete local files while the cache uses them.");
|
||||
|
||||
var path = GetLocalFilesPath();
|
||||
var localMediaDbPath = Path.Combine(path, "NuCache.Media.db");
|
||||
if (File.Exists(localMediaDbPath))
|
||||
File.Delete(localMediaDbPath);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Environment
|
||||
@@ -660,38 +638,13 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
|
||||
#region Handle Notifications
|
||||
|
||||
// note: if the service is not ready, ie _isReady is false, then notifications are ignored
|
||||
|
||||
// SetUmbracoVersionStep issues a DistributedCache.Instance.RefreshAll...() call which should cause
|
||||
// the entire content, media etc caches to reload from database -- and then the app restarts -- however,
|
||||
// at the time SetUmbracoVersionStep runs, Umbraco is not fully initialized and therefore some property
|
||||
// value converters, etc are not registered, and rebuilding the NuCache may not work properly.
|
||||
//
|
||||
// More details: ApplicationContext.IsConfigured being false, ApplicationEventHandler.ExecuteWhen... is
|
||||
// called and in most cases events are skipped, so property value converters are not registered or
|
||||
// removed, so PublishedPropertyType either initializes with the wrong converter, or throws because it
|
||||
// detects more than one converter for a property type.
|
||||
//
|
||||
// It's not an issue for XmlStore - the app restart takes place *after* the install has refreshed the
|
||||
// cache, and XmlStore just writes a new umbraco.config file upon RefreshAll, so that's OK.
|
||||
//
|
||||
// But for NuCache... we cannot rebuild the cache now. So it will NOT work and we are not fixing it,
|
||||
// because now we should ALWAYS run with the database server messenger, and then the RefreshAll will
|
||||
// be processed as soon as we are configured and the messenger processes instructions.
|
||||
|
||||
// note: notifications for content type and data type changes should be invoked with the
|
||||
// pure live model factory, if any, locked and refreshed - see ContentTypeCacheRefresher and
|
||||
// DataTypeCacheRefresher
|
||||
|
||||
public override void Notify(ContentCacheRefresher.JsonPayload[] payloads, out bool draftChanged, out bool publishedChanged)
|
||||
{
|
||||
// no cache, trash everything
|
||||
if (_isReady == false)
|
||||
{
|
||||
DeleteLocalFilesForContent();
|
||||
draftChanged = publishedChanged = true;
|
||||
return;
|
||||
}
|
||||
EnsureCaches();
|
||||
|
||||
using (_contentStore.GetScopedWriteLock(_scopeProvider))
|
||||
{
|
||||
@@ -785,13 +738,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
/// <inheritdoc />
|
||||
public override void Notify(MediaCacheRefresher.JsonPayload[] payloads, out bool anythingChanged)
|
||||
{
|
||||
// no cache, trash everything
|
||||
if (_isReady == false)
|
||||
{
|
||||
DeleteLocalFilesForMedia();
|
||||
anythingChanged = true;
|
||||
return;
|
||||
}
|
||||
EnsureCaches();
|
||||
|
||||
using (_mediaStore.GetScopedWriteLock(_scopeProvider))
|
||||
{
|
||||
@@ -878,9 +825,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
/// <inheritdoc />
|
||||
public override void Notify(ContentTypeCacheRefresher.JsonPayload[] payloads)
|
||||
{
|
||||
// no cache, nothing we can do
|
||||
if (_isReady == false)
|
||||
return;
|
||||
EnsureCaches();
|
||||
|
||||
foreach (var payload in payloads)
|
||||
_logger.Debug<PublishedSnapshotService, ContentTypeChangeTypes, string,int>("Notified {ChangeTypes} for {ItemType} {ItemId}", payload.ChangeTypes, payload.ItemType, payload.Id);
|
||||
@@ -960,9 +905,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
|
||||
public override void Notify(DataTypeCacheRefresher.JsonPayload[] payloads)
|
||||
{
|
||||
// no cache, nothing we can do
|
||||
if (_isReady == false)
|
||||
return;
|
||||
EnsureCaches();
|
||||
|
||||
var idsA = payloads.Select(x => x.Id).ToArray();
|
||||
|
||||
@@ -1000,9 +943,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
|
||||
public override void Notify(DomainCacheRefresher.JsonPayload[] payloads)
|
||||
{
|
||||
// no cache, nothing we can do
|
||||
if (_isReady == false)
|
||||
return;
|
||||
EnsureCaches();
|
||||
|
||||
// see note in LockAndLoadContent
|
||||
using (_domainStore.GetScopedWriteLock(_scopeProvider))
|
||||
|
||||
Reference in New Issue
Block a user