Fixes U4-10851 - Unzip Umbraco packages into a flat structure, so it supports packages that have files at the root, along with some packages that have the files nested insider another guid folder

This commit is contained in:
Warren Buckley
2018-01-23 10:38:41 +00:00
parent 05c12d1f27
commit d1db38182f

View File

@@ -763,7 +763,21 @@ namespace umbraco.cms.businesslogic.packager
if (Directory.Exists(tempDir)) Directory.Delete(tempDir, true);
Directory.CreateDirectory(tempDir);
ZipFile.ExtractToDirectory(zipName, tempDir);
//Have to open zip & get each entry & unzip to flatten
//Some Umbraco packages are nested in another folder, where others have all the files at the root
using (var archive = ZipFile.OpenRead(zipName))
{
foreach (var entry in archive.Entries)
{
//Name will be empty if it's a folder
//Otherwise its the filename - where FullName will include any nested folders too
if (string.IsNullOrEmpty(entry.Name) == false)
{
var fullPath = Path.Combine(tempDir, entry.Name);
entry.ExtractToFile(fullPath);
}
}
}
if (deleteFile)
{