add defensive logic to package installer
This commit is contained in:
parent
3a79fa074a
commit
82221f54c5
|
@ -190,7 +190,7 @@ else
|
|||
try
|
||||
{
|
||||
await PackageService.InstallPackagesAsync();
|
||||
AddModuleMessage(string.Format(Localizer["Success.Translation.Install"], NavigateUrl("admin/system")), MessageType.Success);
|
||||
AddModuleMessage(string.Format(Localizer["Success.Language.Install"], NavigateUrl("admin/system")), MessageType.Success);
|
||||
_install = false;
|
||||
StateHasChanged();
|
||||
}
|
||||
|
|
|
@ -30,15 +30,12 @@ namespace Oqtane.Infrastructure
|
|||
|
||||
public void InstallPackages()
|
||||
{
|
||||
if (!InstallPackages(_environment.WebRootPath, _environment.ContentRootPath))
|
||||
{
|
||||
// error installing packages
|
||||
}
|
||||
InstallPackages(_environment.WebRootPath, _environment.ContentRootPath);
|
||||
}
|
||||
|
||||
public static bool InstallPackages(string webRootPath, string contentRootPath)
|
||||
{
|
||||
bool install = false;
|
||||
bool install = true;
|
||||
string binPath = Path.GetDirectoryName(Assembly.GetEntryAssembly()?.Location);
|
||||
|
||||
string sourceFolder = Path.Combine(contentRootPath, "Packages");
|
||||
|
@ -81,6 +78,8 @@ namespace Oqtane.Infrastructure
|
|||
|
||||
// iterate through Nuget packages in source folder
|
||||
foreach (string packagename in Directory.GetFiles(sourceFolder, "*.nupkg"))
|
||||
{
|
||||
try
|
||||
{
|
||||
// iterate through files
|
||||
using (ZipArchive archive = ZipFile.OpenRead(packagename))
|
||||
|
@ -170,10 +169,16 @@ namespace Oqtane.Infrastructure
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// problem installing package - logging is not possible as this is a static method
|
||||
Debug.WriteLine($"Oqtane Error: Installing Package {packagename} - {ex}");
|
||||
install = false;
|
||||
}
|
||||
|
||||
// remove package
|
||||
File.Delete(packagename);
|
||||
install = true;
|
||||
}
|
||||
|
||||
return install;
|
||||
|
|
Loading…
Reference in New Issue
Block a user