small cleanups

This commit is contained in:
Shannon
2021-06-11 12:47:35 -06:00
parent e8201a09ef
commit 1297254cc3
20 changed files with 87 additions and 85 deletions

View File

@@ -5,8 +5,6 @@ namespace Umbraco.Cms.Core.Packaging
/// </summary>
public interface ICreatedPackagesRepository : IPackageDefinitionRepository
{
// TODO: This will need to change, it will export the XML
/// <summary>
/// Creates the package file and returns it's physical path
/// </summary>

View File

@@ -12,6 +12,11 @@ namespace Umbraco.Cms.Core.Packaging
[DataContract(IsReference = true)]
public class InstallationSummary
{
public InstallationSummary(string packageName)
{
PackageName = packageName;
}
public InstallWarnings Warnings { get; set; } = new InstallWarnings();
public IEnumerable<IDataType> DataTypesInstalled { get; set; } = Enumerable.Empty<IDataType>();
@@ -24,6 +29,7 @@ namespace Umbraco.Cms.Core.Packaging
public IEnumerable<IFile> StylesheetsInstalled { get; set; } = Enumerable.Empty<IFile>();
public IEnumerable<IContent> ContentInstalled { get; set; } = Enumerable.Empty<IContent>();
public IEnumerable<IMedia> MediaInstalled { get; set; } = Enumerable.Empty<IMedia>();
public string PackageName { get; }
public override string ToString()
{

View File

@@ -11,7 +11,6 @@ namespace Umbraco.Cms.Core.Packaging
/// </summary>
public abstract class PackageMigrationPlan : MigrationPlan, IDiscoverable
{
// TODO: Should this take a name from an attribute or an abstract property?
protected PackageMigrationPlan(string name) : base(name)
{
// A call to From must be done first

View File

@@ -0,0 +1,65 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Extensions.Logging;
using Umbraco.Extensions;
namespace Umbraco.Cms.Core.Packaging
{
public class PendingPackageMigrations
{
private readonly ILogger<PendingPackageMigrations> _logger;
private readonly PackageMigrationPlanCollection _packageMigrationPlans;
public PendingPackageMigrations(
ILogger<PendingPackageMigrations> logger,
PackageMigrationPlanCollection packageMigrationPlans)
{
_logger = logger;
_packageMigrationPlans = packageMigrationPlans;
}
/// <summary>
/// Returns what package migration names are pending
/// </summary>
/// <param name="keyValues">
/// These are the key/value pairs from the keyvalue storage of migration names and their final values
/// </param>
/// <returns></returns>
public IReadOnlyList<string> GetUmbracoPendingPackageMigrations(IReadOnlyDictionary<string, string> keyValues)
{
var packageMigrationPlans = _packageMigrationPlans.ToList();
var pendingMigrations = new List<string>(packageMigrationPlans.Count);
foreach (PackageMigrationPlan plan in packageMigrationPlans)
{
string currentMigrationState = null;
var planKeyValueKey = Constants.Conventions.Migrations.KeyValuePrefix + plan.Name;
if (keyValues.TryGetValue(planKeyValueKey, out var value))
{
currentMigrationState = value;
if (!plan.FinalState.InvariantEquals(value))
{
// Not equal so we need to run
pendingMigrations.Add(plan.Name);
}
}
else
{
// If there is nothing in the DB then we need to run
pendingMigrations.Add(plan.Name);
}
_logger.LogDebug("Final package migration for {PackagePlan} state is {FinalMigrationState}, database contains {DatabaseState}",
plan.Name,
plan.FinalState,
currentMigrationState ?? "<null>");
}
return pendingMigrations;
}
}
}

View File

@@ -1,24 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Core.Models.Packaging;
namespace Umbraco.Cms.Core.Packaging
{
// TODO: Probably can be killed
[Serializable]
[DataContract(IsReference = true)]
public class UninstallationSummary
{
public IEnumerable<IDataType> DataTypesUninstalled { get; set; } = Enumerable.Empty<IDataType>();
public IEnumerable<ILanguage> LanguagesUninstalled { get; set; } = Enumerable.Empty<ILanguage>();
public IEnumerable<IDictionaryItem> DictionaryItemsUninstalled { get; set; } = Enumerable.Empty<IDictionaryItem>();
public IEnumerable<IMacro> MacrosUninstalled { get; set; } = Enumerable.Empty<IMacro>();
public IEnumerable<ITemplate> TemplatesUninstalled { get; set; } = Enumerable.Empty<ITemplate>();
public IEnumerable<IContentType> DocumentTypesUninstalled { get; set; } = Enumerable.Empty<IContentType>();
public IEnumerable<IFile> StylesheetsUninstalled { get; set; } = Enumerable.Empty<IFile>();
}
}