Merge pull request #2299 from chlupac/InstallManFix

Fix - InstallationManager crash when package folders are missing
This commit is contained in:
Shaun Walker 2022-07-19 13:12:43 -04:00 committed by GitHub
commit ded6c9c199
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -48,15 +48,19 @@ namespace Oqtane.Infrastructure
}
// move packages to secure /Packages folder
foreach (var folder in "Modules,Themes,Packages".Split(","))
foreach (var folderName in "Modules,Themes,Packages".Split(","))
{
foreach(var file in Directory.GetFiles(Path.Combine(webRootPath, folder), "*.nupkg*"))
string folder = Path.Combine(webRootPath, folderName);
if (Directory.Exists(folder))
{
foreach (var file in Directory.GetFiles(folder, "*.nupkg*"))
{
var destinationFile = Path.Combine(sourceFolder, Path.GetFileName(file));
if (File.Exists(destinationFile))
{
File.Delete(destinationFile);
}
if (destinationFile.ToLower().EndsWith(".nupkg.bak"))
{
// leave a copy in the current folder as it is distributed with the core framework
@ -69,6 +73,11 @@ namespace Oqtane.Infrastructure
}
}
}
else
{
Directory.CreateDirectory(folder);
}
}
// iterate through Nuget packages in source folder
foreach (string packagename in Directory.GetFiles(sourceFolder, "*.nupkg"))