@@ -236,51 +236,52 @@ async Task<bool> DecompressAsyncWithSharpZipLib(string archiveFilePath, string d
236236 {
237237 long processedBytes = 0 ;
238238 int processedFiles = 0 ;
239-
240- foreach ( ZipEntry zipEntry in zipFile )
239+ await Task . Run ( async ( ) =>
241240 {
242- if ( statusCard . CancellationToken . IsCancellationRequested )
241+ foreach ( ZipEntry zipEntry in zipFile )
243242 {
244- isSuccess = false ;
245- break ;
246- }
247-
248- if ( ! zipEntry . IsFile )
249- {
250- continue ; // Ignore directories
251- }
243+ if ( statusCard . CancellationToken . IsCancellationRequested )
244+ {
245+ isSuccess = false ;
246+ break ;
247+ }
252248
253- string entryFileName = zipEntry . Name ;
254- string fullZipToPath = Path . Combine ( destinationFolderPath , entryFileName ) ;
255- string directoryName = Path . GetDirectoryName ( fullZipToPath ) ;
249+ if ( ! zipEntry . IsFile )
250+ {
251+ continue ; // Ignore directories
252+ }
256253
257- if ( ! Directory . Exists ( directoryName ) )
258- {
259- Directory . CreateDirectory ( directoryName ) ;
260- }
254+ string entryFileName = zipEntry . Name ;
255+ string fullZipToPath = Path . Combine ( destinationFolderPath , entryFileName ) ;
256+ string directoryName = Path . GetDirectoryName ( fullZipToPath ) ;
261257
262- byte [ ] buffer = new byte [ 4096 ] ; // 4K is a good default
263- using ( Stream zipStream = zipFile . GetInputStream ( zipEntry ) )
264- using ( FileStream streamWriter = File . Create ( fullZipToPath ) )
265- {
266- await ThreadingService . ExecuteOnUiThreadAsync ( ( ) =>
258+ if ( ! Directory . Exists ( directoryName ) )
267259 {
268- fsProgress . FileName = entryFileName ;
269- fsProgress . Report ( ) ;
270- } ) ;
260+ Directory . CreateDirectory ( directoryName ) ;
261+ }
271262
272- StreamUtils . Copy ( zipStream , streamWriter , buffer ) ;
273- }
274- processedBytes += zipEntry . Size ;
275- if ( fsProgress . TotalSize > 0 )
276- {
277- fsProgress . Report ( processedBytes / ( double ) fsProgress . TotalSize * 100 ) ;
263+ byte [ ] buffer = new byte [ 4096 ] ; // 4K is a good default
264+ using ( Stream zipStream = zipFile . GetInputStream ( zipEntry ) )
265+ using ( FileStream streamWriter = File . Create ( fullZipToPath ) )
266+ {
267+ await ThreadingService . ExecuteOnUiThreadAsync ( ( ) =>
268+ {
269+ fsProgress . FileName = entryFileName ;
270+ fsProgress . Report ( ) ;
271+ } ) ;
272+
273+ StreamUtils . Copy ( zipStream , streamWriter , buffer ) ;
274+ }
275+ processedBytes += zipEntry . Size ;
276+ if ( fsProgress . TotalSize > 0 )
277+ {
278+ fsProgress . Report ( processedBytes / ( double ) fsProgress . TotalSize * 100 ) ;
279+ }
280+ processedFiles ++ ;
281+ fsProgress . AddProcessedItemsCount ( 1 ) ;
282+ fsProgress . Report ( ) ;
278283 }
279- processedFiles ++ ;
280- fsProgress . AddProcessedItemsCount ( 1 ) ;
281- fsProgress . Report ( ) ;
282- }
283-
284+ } ) ;
284285 if ( ! statusCard . CancellationToken . IsCancellationRequested )
285286 {
286287 isSuccess = true ;
0 commit comments