mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-14 02:44:52 +08:00
Better error message when package installation failed
Work Item: 17194 --HG-- branch : 1.x
This commit is contained in:
@@ -80,7 +80,8 @@ namespace Orchard.Packaging.Controllers {
|
|||||||
if (!url.StartsWith("http")) {
|
if (!url.StartsWith("http")) {
|
||||||
ModelState.AddModelError("Url", T("The Url is not valid").Text);
|
ModelState.AddModelError("Url", T("The Url is not valid").Text);
|
||||||
}
|
}
|
||||||
} else if (String.IsNullOrWhiteSpace(url)) {
|
}
|
||||||
|
else if (String.IsNullOrWhiteSpace(url)) {
|
||||||
ModelState.AddModelError("Url", T("Url is required").Text);
|
ModelState.AddModelError("Url", T("Url is required").Text);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -97,7 +98,8 @@ namespace Orchard.Packaging.Controllers {
|
|||||||
if (String.IsNullOrWhiteSpace(title)) {
|
if (String.IsNullOrWhiteSpace(title)) {
|
||||||
ModelState.AddModelError("Url", T("The feed has no title.").Text);
|
ModelState.AddModelError("Url", T("The feed has no title.").Text);
|
||||||
}
|
}
|
||||||
} catch {
|
}
|
||||||
|
catch {
|
||||||
ModelState.AddModelError("Url", T("The url of the feed or its content is not valid.").Text);
|
ModelState.AddModelError("Url", T("The url of the feed or its content is not valid.").Text);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -108,7 +110,8 @@ namespace Orchard.Packaging.Controllers {
|
|||||||
_notifier.Information(T("The feed has been added successfully."));
|
_notifier.Information(T("The feed has been added successfully."));
|
||||||
|
|
||||||
return RedirectToAction("Sources");
|
return RedirectToAction("Sources");
|
||||||
} catch (Exception exception) {
|
}
|
||||||
|
catch (Exception exception) {
|
||||||
_notifier.Error(T("Adding feed failed: {0}", exception.Message));
|
_notifier.Error(T("Adding feed failed: {0}", exception.Message));
|
||||||
return View(new PackagingAddSourceViewModel { Url = url });
|
return View(new PackagingAddSourceViewModel { Url = url });
|
||||||
}
|
}
|
||||||
@@ -138,7 +141,8 @@ namespace Orchard.Packaging.Controllers {
|
|||||||
try {
|
try {
|
||||||
var sourceExtensions = getList(source);
|
var sourceExtensions = getList(source);
|
||||||
extensions = extensions == null ? sourceExtensions : extensions.Concat(sourceExtensions);
|
extensions = extensions == null ? sourceExtensions : extensions.Concat(sourceExtensions);
|
||||||
} catch (Exception ex) {
|
}
|
||||||
|
catch (Exception ex) {
|
||||||
Logger.Error(ex, "Error loading extensions from gallery source '{0}'. {1}.", source.FeedTitle, ex.Message);
|
Logger.Error(ex, "Error loading extensions from gallery source '{0}'. {1}.", source.FeedTitle, ex.Message);
|
||||||
_notifier.Error(T("Error loading extensions from gallery source '{0}'. {1}.", source.FeedTitle, ex.Message));
|
_notifier.Error(T("Error loading extensions from gallery source '{0}'. {1}.", source.FeedTitle, ex.Message));
|
||||||
}
|
}
|
||||||
@@ -161,7 +165,15 @@ namespace Orchard.Packaging.Controllers {
|
|||||||
return HttpNotFound();
|
return HttpNotFound();
|
||||||
}
|
}
|
||||||
|
|
||||||
_packageManager.Install(packageId, version, source.FeedUrl, HostingEnvironment.MapPath("~/"));
|
try {
|
||||||
|
_packageManager.Install(packageId, version, source.FeedUrl, HostingEnvironment.MapPath("~/"));
|
||||||
|
}
|
||||||
|
catch (Exception exception) {
|
||||||
|
_notifier.Error(T("Package installation failed."));
|
||||||
|
for (Exception scan = exception; scan != null; scan = scan.InnerException) {
|
||||||
|
_notifier.Error(T("{0}", scan.Message));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return RedirectToAction(redirectTo == "Themes" ? "Themes" : "Modules");
|
return RedirectToAction(redirectTo == "Themes" ? "Themes" : "Modules");
|
||||||
}
|
}
|
||||||
|
@@ -98,16 +98,15 @@ namespace Orchard.Packaging.Controllers {
|
|||||||
file.SaveAs(fullFileName);
|
file.SaveAs(fullFileName);
|
||||||
PackageInfo info = _packageManager.Install(new ZipPackage(fullFileName), _appDataFolderRoot.RootFolder, HostingEnvironment.MapPath("~/"));
|
PackageInfo info = _packageManager.Install(new ZipPackage(fullFileName), _appDataFolderRoot.RootFolder, HostingEnvironment.MapPath("~/"));
|
||||||
System.IO.File.Delete(fullFileName);
|
System.IO.File.Delete(fullFileName);
|
||||||
|
|
||||||
_notifier.Information(T("Installed package \"{0}\", version {1} of type \"{2}\" at location \"{3}\"",
|
|
||||||
info.ExtensionName, info.ExtensionVersion, info.ExtensionType, info.ExtensionPath));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.RedirectLocal(returnUrl, "~/");
|
return this.RedirectLocal(returnUrl, "~/");
|
||||||
} catch (Exception exception) {
|
}
|
||||||
|
catch (Exception exception) {
|
||||||
|
_notifier.Error(T("Package uploading and installation failed."));
|
||||||
for (Exception scan = exception; scan != null; scan = scan.InnerException) {
|
for (Exception scan = exception; scan != null; scan = scan.InnerException) {
|
||||||
_notifier.Error(T("Uploading module package failed: {0}", exception.Message));
|
_notifier.Error(T("{0}", scan.Message));
|
||||||
}
|
}
|
||||||
|
|
||||||
return Redirect(retryUrl);
|
return Redirect(retryUrl);
|
||||||
@@ -124,7 +123,8 @@ namespace Orchard.Packaging.Controllers {
|
|||||||
_notifier.Information(T("Uninstalled package \"{0}\"", id));
|
_notifier.Information(T("Uninstalled package \"{0}\"", id));
|
||||||
|
|
||||||
return this.RedirectLocal(returnUrl, "~/");
|
return this.RedirectLocal(returnUrl, "~/");
|
||||||
} catch (Exception exception) {
|
}
|
||||||
|
catch (Exception exception) {
|
||||||
for (Exception scan = exception; scan != null; scan = scan.InnerException) {
|
for (Exception scan = exception; scan != null; scan = scan.InnerException) {
|
||||||
_notifier.Error(T("Uninstall failed: {0}", exception.Message));
|
_notifier.Error(T("Uninstall failed: {0}", exception.Message));
|
||||||
}
|
}
|
||||||
|
@@ -1,7 +1,11 @@
|
|||||||
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Web.Hosting;
|
||||||
using NuGet;
|
using NuGet;
|
||||||
using Orchard.Environment.Extensions;
|
using Orchard.Environment.Extensions;
|
||||||
using Orchard.Environment.Extensions.Models;
|
using Orchard.Environment.Extensions.Models;
|
||||||
|
using Orchard.Localization;
|
||||||
|
using Orchard.UI.Notify;
|
||||||
|
|
||||||
namespace Orchard.Packaging.Services {
|
namespace Orchard.Packaging.Services {
|
||||||
[OrchardFeature("PackagingServices")]
|
[OrchardFeature("PackagingServices")]
|
||||||
@@ -9,14 +13,35 @@ namespace Orchard.Packaging.Services {
|
|||||||
private readonly IExtensionManager _extensionManager;
|
private readonly IExtensionManager _extensionManager;
|
||||||
private readonly IPackageBuilder _packageBuilder;
|
private readonly IPackageBuilder _packageBuilder;
|
||||||
private readonly IPackageInstaller _packageExpander;
|
private readonly IPackageInstaller _packageExpander;
|
||||||
|
private readonly INotifier _notifier;
|
||||||
|
|
||||||
public PackageManager(
|
public PackageManager(
|
||||||
IExtensionManager extensionManager,
|
IExtensionManager extensionManager,
|
||||||
IPackageBuilder packageBuilder,
|
IPackageBuilder packageBuilder,
|
||||||
IPackageInstaller packageExpander) {
|
IPackageInstaller packageExpander,
|
||||||
|
INotifier notifier) {
|
||||||
_extensionManager = extensionManager;
|
_extensionManager = extensionManager;
|
||||||
_packageBuilder = packageBuilder;
|
_packageBuilder = packageBuilder;
|
||||||
_packageExpander = packageExpander;
|
_packageExpander = packageExpander;
|
||||||
|
_notifier = notifier;
|
||||||
|
|
||||||
|
T = NullLocalizer.Instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Localizer T { get; set; }
|
||||||
|
|
||||||
|
private PackageInfo DoInstall(Func<PackageInfo> installer) {
|
||||||
|
try {
|
||||||
|
return installer();
|
||||||
|
}
|
||||||
|
catch (Exception exception) {
|
||||||
|
var message = T(
|
||||||
|
"There was an error installing the requested package. " +
|
||||||
|
"This can happen if the server does not have write access to the '~/Modules' or '~/Themes' folder of the web site. " +
|
||||||
|
"If the site is running in shared hosted environement, adding write access to these folders sometimes needs to be done manually through the Hoster control panel. " +
|
||||||
|
"Once Themes and Modules have been installed, it is recommended to remove write access to these folders.");
|
||||||
|
throw new OrchardException(message, exception);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#region IPackageManager Members
|
#region IPackageManager Members
|
||||||
@@ -34,13 +59,12 @@ namespace Orchard.Packaging.Services {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public PackageInfo Install(IPackage package, string location, string applicationPath)
|
public PackageInfo Install(IPackage package, string location, string applicationPath) {
|
||||||
{
|
return DoInstall(() => _packageExpander.Install(package, location, applicationPath));
|
||||||
return _packageExpander.Install(package, location, applicationPath);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public PackageInfo Install(string packageId, string version, string location, string applicationPath) {
|
public PackageInfo Install(string packageId, string version, string location, string applicationPath) {
|
||||||
return _packageExpander.Install(packageId, version, location, applicationPath);
|
return DoInstall(() => _packageExpander.Install(packageId, version, location, applicationPath));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Uninstall(string packageId, string applicationPath) {
|
public void Uninstall(string packageId, string applicationPath) {
|
||||||
|
Reference in New Issue
Block a user