Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions src/Files.App/Services/Storage/StorageArchiveService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Files.Shared.Helpers;
using ICSharpCode.SharpZipLib.Core;
using ICSharpCode.SharpZipLib.Zip;
using Microsoft.Extensions.Logging;
using SevenZip;
using System.IO;
using System.Text;
Expand Down Expand Up @@ -137,9 +138,10 @@ async Task<bool> DecompressAsyncWithSevenZip(string archiveFilePath, string dest

isSuccess = true;
}
catch
catch (Exception ex)
{
isSuccess = false;
App.Logger.LogError(ex, "SevenZipLib error extracting archive file.");
}
finally
{
Expand Down Expand Up @@ -288,7 +290,7 @@ await ThreadingService.ExecuteOnUiThreadAsync(() =>
catch (Exception ex)
{
isSuccess = false;
Console.WriteLine($"Error during decompression: {ex.Message}");
App.Logger.LogError(ex, "SharpZipLib error during decompression.");
}
finally
{
Expand Down Expand Up @@ -362,7 +364,7 @@ public async Task<bool> IsEncodingUndeterminedAsync(string archiveFilePath)
}
catch (Exception ex)
{
Console.WriteLine($"SharpZipLib error: {ex.Message}");
App.Logger.LogError(ex, "SharpZipLib error.");
return true;
}
}
Expand Down Expand Up @@ -398,7 +400,7 @@ public async Task<bool> IsEncodingUndeterminedAsync(string archiveFilePath)
}
catch (Exception ex)
{
Console.WriteLine($"SharpZipLib error: {ex.Message}");
App.Logger.LogError(ex, "SharpZipLib error detecting encoding.");
return null;
}
}
Expand All @@ -409,8 +411,9 @@ public async Task<bool> IsEncodingUndeterminedAsync(string archiveFilePath)
return await FilesystemTasks.Wrap(async () =>
{
BaseStorageFile archive = await StorageHelpers.ToStorageItem<BaseStorageFile>(archiveFilePath);

var extractor = new SevenZipExtractor(await archive.OpenStreamForReadAsync(), password);
var extractor = string.IsNullOrEmpty(password)
? new SevenZipExtractor(archive.Path)
: new SevenZipExtractor(archive.Path, password);

// Force to load archive (1665013614u)
return extractor?.ArchiveFileData is null ? null : extractor;
Expand Down
Loading