public static JsonResponse UninstallPackage(string pkgId)
{
try
{
var packageManager = new PackageManager(
_repository,
new DefaultPackagePathResolver(BlogSettings.Instance.GalleryFeedUrl),
new PhysicalFileSystem(HttpContext.Current.Server.MapPath(Utils.ApplicationRelativeWebRoot + "App_Data/packages"))
);
var package = _repository.FindPackage(pkgId);
if (package == null)
return new JsonResponse { Success = false, Message = "Package " + pkgId + " not found" };
packageManager.UninstallPackage(package, true);
FileSystem.UninstallPackage(package.Id);
BlogService.DeletePackage(pkgId);
// reset cache
Blog.CurrentInstance.Cache.Remove(Constants.CacheKey);
Utils.Log(string.Format("Uninstalled package {0} by {1}", pkgId, Security.CurrentUser.Identity.Name));
}
catch (Exception ex)
{
Utils.Log("BlogEngine.Core.Packaging.Installer.UninstallPackage(" + pkgId + ")", ex);
return new JsonResponse { Success = false, Message = "Error uninstalling package, see logs for details" };
}
return new JsonResponse { Success = true, Message = "Package successfully uninstalled" };
}