Skip to content

Commit

Permalink
Fixed a bug inside the ZipArchiveExtensions class
Browse files Browse the repository at this point in the history
A bug caused the ZipArchiveExtensions class to ignore EVERY file inside the archive and therefor didn't unpack any.
Forgot to put a ! in front of  the check if the filename is empty and that caused the problem
  • Loading branch information
daredloco committed Oct 24, 2020
1 parent c3dcfb1 commit f8a78a3
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
1 change: 1 addition & 0 deletions GitInstaller/GitInstaller/GitInstaller.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<None Include="zipsettings.json" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
Expand Down
4 changes: 2 additions & 2 deletions GitInstaller/GitInstaller/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,5 @@
// Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden,
// indem Sie "*" wie unten gezeigt eingeben:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.4.0.0")]
[assembly: AssemblyFileVersion("1.4.0.0")]
[assembly: AssemblyVersion("1.4.1.0")]
[assembly: AssemblyFileVersion("1.4.1.0")]
6 changes: 4 additions & 2 deletions GitInstaller/GitInstaller/ZipArchiveExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public static void ExtractToDirectory(this ZipArchive archive, string destinatio
if (!Directory.Exists(directory))
Directory.CreateDirectory(directory);

if (string.IsNullOrEmpty(file.Name) && file.Name != "zipsettings.json")
if (!string.IsNullOrEmpty(file.Name) && file.Name != "zipsettings.json")
file.ExtractToFile(completeFileName, true);
}
}
Expand All @@ -37,18 +37,20 @@ public static void ExtractWithSettings(this ZipArchive archive, string destinati
ZipSettings settings = ZipSettings.FromStream(archive.GetEntry("zipsettings.json").Open());
if(settings == null)
{
Console.WriteLine("Settings is NULL!");
ExtractToDirectory(archive, destinationDirectoryName, overwrite);
return;
}
foreach(ZipArchiveEntry file in archive.Entries)
{
Console.WriteLine(file.Name);
string completeFileName = Path.Combine(destinationDirectoryName, settings.Subfolder, file.FullName);
string directory = Path.GetDirectoryName(completeFileName);

if (!Directory.Exists(directory))
Directory.CreateDirectory(directory);

if (string.IsNullOrEmpty(file.Name) && file.Name != "zipsettings.json")
if (!string.IsNullOrEmpty(file.Name) && file.Name != "zipsettings.json")
file.ExtractToFile(completeFileName, overwrite);
}
}
Expand Down

0 comments on commit f8a78a3

Please sign in to comment.