Skip to content

Commit

Permalink
Fixed extracting auto update
Browse files Browse the repository at this point in the history
  • Loading branch information
TekkaGB committed Jun 28, 2022
1 parent 467b910 commit e15e39d
Showing 1 changed file with 20 additions and 27 deletions.
47 changes: 20 additions & 27 deletions Unverum/ZipExtractor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,45 +20,38 @@ public class ZipExtractor : IPackageExtractor
{
try
{
if (Path.GetExtension(sourceFilePath).Equals(".7z", StringComparison.InvariantCultureIgnoreCase))
using (var archive = SevenZipArchive.Open(sourceFilePath))
{
using (var archive = SevenZipArchive.Open(sourceFilePath))
var reader = archive.ExtractAllEntries();
while (reader.MoveToNextEntry())
{
var reader = archive.ExtractAllEntries();
while (reader.MoveToNextEntry())
{
if (!reader.Entry.IsDirectory)
reader.WriteEntryToDirectory(destDirPath, new ExtractionOptions()
{
ExtractFullPath = true,
Overwrite = true
});
}
if (!reader.Entry.IsDirectory)
reader.WriteEntryToDirectory(destDirPath, new ExtractionOptions()
{
ExtractFullPath = true,
Overwrite = true
});
}
}
else
}
catch
{
using (Stream stream = File.OpenRead(sourceFilePath))
using (var reader = ReaderFactory.Open(stream))
{
using (Stream stream = File.OpenRead(sourceFilePath))
using (var reader = ReaderFactory.Open(stream))
while (reader.MoveToNextEntry())
{
while (reader.MoveToNextEntry())
if (!reader.Entry.IsDirectory)
{
if (!reader.Entry.IsDirectory)
reader.WriteEntryToDirectory(destDirPath, new ExtractionOptions()
{
reader.WriteEntryToDirectory(destDirPath, new ExtractionOptions()
{
ExtractFullPath = true,
Overwrite = true
});
}
ExtractFullPath = true,
Overwrite = true
});
}
}
}
}
catch
{
Global.logger.WriteLine("Failed to extract update", LoggerType.Error);
}
File.Delete(@$"{sourceFilePath}");
// Move the folders to the right place
string parentPath = Directory.GetParent(destDirPath).FullName;
Expand Down

0 comments on commit e15e39d

Please sign in to comment.