Allow nucache content and/or media db files to be reused if they already exist.

This commit is contained in:
JohnBlair
2019-10-17 18:46:11 +01:00
committed by Shannon
parent 7afdf9e9a9
commit 7ace5baf9b
2 changed files with 20 additions and 16 deletions

View File

@@ -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<ComponentCollectionBuilder>();
var composers = new Composers(composition, composerTypes, ProfilingLogger);
composers.Compose();
// get composers, and compose
var composerTypes = ResolveComposerTypes(typeLoader);
composition.WithCollectionBuilder<ComponentCollectionBuilder>();
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<ComponentCollection>();
_components.Initialize();
}
// create & initialize the components
_components = _factory.GetInstance<ComponentCollection>();
_components.Initialize();
}
catch (Exception e)
{

View File

@@ -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<PublishedSnapshotService>($"Registered with MainDom, local db exists? {_localDbExists}");
},