44using Files . Shared . Helpers ;
55using ICSharpCode . SharpZipLib . Core ;
66using ICSharpCode . SharpZipLib . Zip ;
7+ using Microsoft . Extensions . Logging ;
78using SevenZip ;
89using System . IO ;
910using System . Text ;
@@ -137,9 +138,10 @@ async Task<bool> DecompressAsyncWithSevenZip(string archiveFilePath, string dest
137138
138139 isSuccess = true ;
139140 }
140- catch
141+ catch ( Exception ex )
141142 {
142143 isSuccess = false ;
144+ App . Logger . LogError ( ex , "SevenZipLib error extracting archive file." ) ;
143145 }
144146 finally
145147 {
@@ -288,7 +290,7 @@ await ThreadingService.ExecuteOnUiThreadAsync(() =>
288290 catch ( Exception ex )
289291 {
290292 isSuccess = false ;
291- Console . WriteLine ( $ "Error during decompression: { ex . Message } ") ;
293+ App . Logger . LogError ( ex , "SharpZipLib error during decompression. ") ;
292294 }
293295 finally
294296 {
@@ -362,7 +364,7 @@ public async Task<bool> IsEncodingUndeterminedAsync(string archiveFilePath)
362364 }
363365 catch ( Exception ex )
364366 {
365- Console . WriteLine ( $ "SharpZipLib error: { ex . Message } ") ;
367+ App . Logger . LogError ( ex , "SharpZipLib error. " ) ;
366368 return true ;
367369 }
368370 }
@@ -398,7 +400,7 @@ public async Task<bool> IsEncodingUndeterminedAsync(string archiveFilePath)
398400 }
399401 catch ( Exception ex )
400402 {
401- Console . WriteLine ( $ "SharpZipLib error: { ex . Message } ") ;
403+ App . Logger . LogError ( ex , "SharpZipLib error detecting encoding. " ) ;
402404 return null ;
403405 }
404406 }
@@ -409,8 +411,9 @@ public async Task<bool> IsEncodingUndeterminedAsync(string archiveFilePath)
409411 return await FilesystemTasks . Wrap ( async ( ) =>
410412 {
411413 BaseStorageFile archive = await StorageHelpers . ToStorageItem < BaseStorageFile > ( archiveFilePath ) ;
412-
413- var extractor = new SevenZipExtractor ( await archive . OpenStreamForReadAsync ( ) , password ) ;
414+ var extractor = string . IsNullOrEmpty ( password )
415+ ? new SevenZipExtractor ( archive . Path )
416+ : new SevenZipExtractor ( archive . Path , password ) ;
414417
415418 // Force to load archive (1665013614u)
416419 return extractor ? . ArchiveFileData is null ? null : extractor ;
0 commit comments