Add check for extension with the same ID

This can happen as we collect extensions from different
source locations.

Work Item: 16632

--HG--
branch : dev
This commit is contained in:
Renaud Paquay
2010-12-09 13:07:26 -08:00
parent 1ce6ab190e
commit b91101d2ec

View File

@@ -1,6 +1,8 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc;
using Orchard.Caching;
using Orchard.Environment.Extensions.Loaders;
using Orchard.Environment.Extensions.Models;
@@ -155,6 +157,19 @@ namespace Orchard.Environment.Extensions {
.OrderBy(d => d.Id)
.ToList();
// Check there are no duplicates
var duplicates = availableExtensions.GroupBy(ed => ed.Id).Where(g => g.Count() >= 2).ToList();
if (duplicates.Count() > 0) {
var sb = new StringBuilder();
sb.Append(T("There are multiple extensions with the same name installed in this instance of Orchard.\r\n"));
foreach(var dup in duplicates) {
sb.Append(T("Extension '{0}' has been found from the following locations: {1}.\r\n", dup.Key, string.Join(", ", dup.Select(e => e.Location + "/" + e.Id))));
}
sb.Append(T("This issue can be usually by solved by removing or renamig the conflicting extension."));
Logger.Error(sb.ToString());
throw new OrchardException(new LocalizedString(sb.ToString()));
}
var previousDependencies = _dependenciesFolder.LoadDescriptors().ToList();
var availableExtensionsProbes = availableExtensions.SelectMany(extension => _loaders