4
4
using Files . Shared . Helpers ;
5
5
using ICSharpCode . SharpZipLib . Core ;
6
6
using ICSharpCode . SharpZipLib . Zip ;
7
+ using Microsoft . Extensions . Logging ;
7
8
using SevenZip ;
8
9
using System . IO ;
9
10
using System . Text ;
@@ -137,9 +138,10 @@ async Task<bool> DecompressAsyncWithSevenZip(string archiveFilePath, string dest
137
138
138
139
isSuccess = true ;
139
140
}
140
- catch
141
+ catch ( Exception ex )
141
142
{
142
143
isSuccess = false ;
144
+ App . Logger . LogError ( ex , "SevenZipLib error extracting archive file." ) ;
143
145
}
144
146
finally
145
147
{
@@ -288,7 +290,7 @@ await ThreadingService.ExecuteOnUiThreadAsync(() =>
288
290
catch ( Exception ex )
289
291
{
290
292
isSuccess = false ;
291
- Console . WriteLine ( $ "Error during decompression: { ex . Message } ") ;
293
+ App . Logger . LogError ( ex , "SharpZipLib error during decompression. ") ;
292
294
}
293
295
finally
294
296
{
@@ -362,7 +364,7 @@ public async Task<bool> IsEncodingUndeterminedAsync(string archiveFilePath)
362
364
}
363
365
catch ( Exception ex )
364
366
{
365
- Console . WriteLine ( $ "SharpZipLib error: { ex . Message } ") ;
367
+ App . Logger . LogError ( ex , "SharpZipLib error. " ) ;
366
368
return true ;
367
369
}
368
370
}
@@ -398,7 +400,7 @@ public async Task<bool> IsEncodingUndeterminedAsync(string archiveFilePath)
398
400
}
399
401
catch ( Exception ex )
400
402
{
401
- Console . WriteLine ( $ "SharpZipLib error: { ex . Message } ") ;
403
+ App . Logger . LogError ( ex , "SharpZipLib error detecting encoding. " ) ;
402
404
return null ;
403
405
}
404
406
}
@@ -409,8 +411,9 @@ public async Task<bool> IsEncodingUndeterminedAsync(string archiveFilePath)
409
411
return await FilesystemTasks . Wrap ( async ( ) =>
410
412
{
411
413
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 ) ;
414
417
415
418
// Force to load archive (1665013614u)
416
419
return extractor ? . ArchiveFileData is null ? null : extractor ;
0 commit comments