From 7ace5baf9b2439ced8d86251e65a5a5be8b308da Mon Sep 17 00:00:00 2001 From: JohnBlair Date: Thu, 17 Oct 2019 18:46:11 +0100 Subject: [PATCH] Allow nucache content and/or media db files to be reused if they already exist. --- src/Umbraco.Core/Runtime/CoreRuntime.cs | 28 ++++++++++--------- .../NuCache/PublishedSnapshotService.cs | 8 ++++-- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/src/Umbraco.Core/Runtime/CoreRuntime.cs b/src/Umbraco.Core/Runtime/CoreRuntime.cs index 5b069641c4..5cca74124d 100644 --- a/src/Umbraco.Core/Runtime/CoreRuntime.cs +++ b/src/Umbraco.Core/Runtime/CoreRuntime.cs @@ -140,23 +140,25 @@ namespace Umbraco.Core.Runtime Compose(composition); // acquire the main domain - if this fails then anything that should be registered with MainDom will not operate - AcquireMainDom(mainDom); + if (AcquireMainDom(mainDom)) + { + // determine our runtime level + DetermineRuntimeLevel(databaseFactory, ProfilingLogger); - // determine our runtime level - DetermineRuntimeLevel(databaseFactory, ProfilingLogger); + // get composers, and compose + var composerTypes = ResolveComposerTypes(typeLoader); + composition.WithCollectionBuilder(); + var composers = new Composers(composition, composerTypes, ProfilingLogger); + composers.Compose(); - // get composers, and compose - var composerTypes = ResolveComposerTypes(typeLoader); - composition.WithCollectionBuilder(); - var composers = new Composers(composition, composerTypes, ProfilingLogger); - composers.Compose(); + // create the factory + _factory = Current.Factory = composition.CreateFactory(); - // create the factory - _factory = Current.Factory = composition.CreateFactory(); + // create & initialize the components + _components = _factory.GetInstance(); + _components.Initialize(); + } - // create & initialize the components - _components = _factory.GetInstance(); - _components.Initialize(); } catch (Exception e) { diff --git a/src/Umbraco.Web/PublishedCache/NuCache/PublishedSnapshotService.cs b/src/Umbraco.Web/PublishedCache/NuCache/PublishedSnapshotService.cs index 3fcf61a7bc..81a3aa9e21 100755 --- a/src/Umbraco.Web/PublishedCache/NuCache/PublishedSnapshotService.cs +++ b/src/Umbraco.Web/PublishedCache/NuCache/PublishedSnapshotService.cs @@ -128,10 +128,12 @@ namespace Umbraco.Web.PublishedCache.NuCache var path = GetLocalFilesPath(); var localContentDbPath = Path.Combine(path, "NuCache.Content.db"); var localMediaDbPath = Path.Combine(path, "NuCache.Media.db"); - _localDbExists = File.Exists(localContentDbPath) && File.Exists(localMediaDbPath); + var localContentDbExists = File.Exists(localContentDbPath); + var localMediaDbExists = File.Exists(localMediaDbPath); + _localDbExists = localContentDbExists && localMediaDbExists; // if both local databases exist then GetTree will open them, else new databases will be created - _localContentDb = BTree.GetTree(localContentDbPath, _localDbExists); - _localMediaDb = BTree.GetTree(localMediaDbPath, _localDbExists); + _localContentDb = BTree.GetTree(localContentDbPath, localContentDbExists); + _localMediaDb = BTree.GetTree(localMediaDbPath, localMediaDbExists); _logger.Info($"Registered with MainDom, local db exists? {_localDbExists}"); },