From 4ec51da7378c07714796f29daa8ab9d4903d697e Mon Sep 17 00:00:00 2001 From: Stephan Date: Thu, 4 Apr 2019 16:42:27 +0200 Subject: [PATCH] NuCache: fix loading the media cache from local files, was missing media --- src/Umbraco.Web/PublishedCache/NuCache/ContentStore.cs | 2 ++ .../PublishedCache/NuCache/PublishedSnapshotService.cs | 10 ++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/Umbraco.Web/PublishedCache/NuCache/ContentStore.cs b/src/Umbraco.Web/PublishedCache/NuCache/ContentStore.cs index 7ab4a64f31..331ec37248 100644 --- a/src/Umbraco.Web/PublishedCache/NuCache/ContentStore.cs +++ b/src/Umbraco.Web/PublishedCache/NuCache/ContentStore.cs @@ -503,6 +503,7 @@ namespace Umbraco.Web.PublishedCache.NuCache } } + // IMPORTANT kits must be sorted out by LEVEL public void SetAll(IEnumerable kits) { var lockInfo = new WriteLockInfo(); @@ -533,6 +534,7 @@ namespace Umbraco.Web.PublishedCache.NuCache } } + // IMPORTANT kits must be sorted out by LEVEL public void SetBranch(int rootContentId, IEnumerable kits) { var lockInfo = new WriteLockInfo(); diff --git a/src/Umbraco.Web/PublishedCache/NuCache/PublishedSnapshotService.cs b/src/Umbraco.Web/PublishedCache/NuCache/PublishedSnapshotService.cs index d34a789581..bf16074040 100755 --- a/src/Umbraco.Web/PublishedCache/NuCache/PublishedSnapshotService.cs +++ b/src/Umbraco.Web/PublishedCache/NuCache/PublishedSnapshotService.cs @@ -356,6 +356,7 @@ namespace Umbraco.Web.PublishedCache.NuCache _logger.Debug("Loading content from database..."); var sw = Stopwatch.StartNew(); + // IMPORTANT GetAllContentSources sorts kits by level var kits = _dataSource.GetAllContentSources(scope); _contentStore.SetAll(kits); sw.Stop(); @@ -370,7 +371,8 @@ namespace Umbraco.Web.PublishedCache.NuCache _logger.Debug("Loading content from local db..."); var sw = Stopwatch.StartNew(); - var kits = _localContentDb.Select(x => x.Value).OrderBy(x => x.Node.Level); + var kits = _localContentDb.Select(x => x.Value) + .OrderBy(x => x.Node.Level); // IMPORTANT sort by level _contentStore.SetAll(kits); sw.Stop(); _logger.Debug("Loaded content from local db ({Duration}ms)", sw.ElapsedMilliseconds); @@ -422,6 +424,7 @@ namespace Umbraco.Web.PublishedCache.NuCache _logger.Debug("Loading media from database..."); var sw = Stopwatch.StartNew(); + // IMPORTANT GetAllMediaSources sorts kits by level var kits = _dataSource.GetAllMediaSources(scope); _mediaStore.SetAll(kits); sw.Stop(); @@ -436,7 +439,8 @@ namespace Umbraco.Web.PublishedCache.NuCache _logger.Debug("Loading media from local db..."); var sw = Stopwatch.StartNew(); - var kits = _localMediaDb.Select(x => x.Value); + var kits = _localMediaDb.Select(x => x.Value) + .OrderBy(x => x.Node.Level); // IMPORTANT sort by level _mediaStore.SetAll(kits); sw.Stop(); _logger.Debug("Loaded media from local db ({Duration}ms)", sw.ElapsedMilliseconds); @@ -647,6 +651,7 @@ namespace Umbraco.Web.PublishedCache.NuCache if (capture.ChangeTypes.HasType(TreeChangeTypes.RefreshBranch)) { // ?? should we do some RV check here? + // IMPORTANT GetbranchContentSources sorts kits by level var kits = _dataSource.GetBranchContentSources(scope, capture.Id); _contentStore.SetBranch(capture.Id, kits); } @@ -738,6 +743,7 @@ namespace Umbraco.Web.PublishedCache.NuCache if (capture.ChangeTypes.HasType(TreeChangeTypes.RefreshBranch)) { // ?? should we do some RV check here? + // IMPORTANT GetbranchContentSources sorts kits by level var kits = _dataSource.GetBranchMediaSources(scope, capture.Id); _mediaStore.SetBranch(capture.Id, kits); }