@@ -285,7 +285,7 @@ public bool Downloader(FileToDownload file, string progress = null)
285285 ProgressBar_Value = 0 ;
286286 HostFilesAd_Visibility = Visibility . Visible ;
287287
288- if ( ( File . Exists ( file . Path + file . FileName + ".dl" ) && String . Compare ( Tools . FileSHA256 ( file . Path + file . FileName + ".dl" ) , file . Sha256 , StringComparison . OrdinalIgnoreCase ) == 0 ) || ( File . Exists ( file . Path + file . FileName ) && String . Compare ( Tools . FileSHA256 ( file . Path + file . FileName ) , file . Sha256 , StringComparison . OrdinalIgnoreCase ) == 0 ) ) { return true ; }
288+ if ( ( File . Exists ( file . Path + file . FileName + ".dl" ) && Tools . FileSHA256 ( file . Path + file . FileName + ".dl" ) == file . Sha256 ) || ( File . Exists ( file . Path + file . FileName ) && Tools . FileSHA256 ( file . Path + file . FileName ) == file . Sha256 ) ) { return true ; }
289289
290290 downloaderTryesCount = 0 ;
291291 webClientTryesCount = 0 ;
@@ -309,6 +309,8 @@ public bool Downloader(FileToDownload file, string progress = null)
309309 ProgressDetails = "Progress: starting download" ;
310310
311311 WebClient webClient = new WebClient ( ) { Proxy = useTor ? Tools . TorProxy : null } ;
312+ webClient . DownloadProgressChanged -= WebClient_DownloadProgressChanged ;
313+ webClient . DownloadFileCompleted -= WebClient_DownloadFileCompleted ;
312314 webClient . DownloadProgressChanged += WebClient_DownloadProgressChanged ;
313315 webClient . DownloadFileCompleted += WebClient_DownloadFileCompleted ;
314316 webClient . DownloadFileAsync ( new Uri ( file . DlLink ) , file . Path + file . FileName + ".dl" ) ;
@@ -320,7 +322,7 @@ public bool Downloader(FileToDownload file, string progress = null)
320322 {
321323 if ( Equals ( currentDownloadBytesReceived , currentDownloadOLastTotalBytesReceived ) )
322324 {
323- if ( DateTime . UtcNow > currentDownloadLastProgressUpdated . AddSeconds ( 5 ) )
325+ if ( DateTime . UtcNow > currentDownloadLastProgressUpdated . AddSeconds ( 10 ) )
324326 {
325327 ProgressDetails = "Progress: restarting..." ;
326328 FileName = FileName + " => fail. restarting app..." ;
@@ -336,10 +338,11 @@ public bool Downloader(FileToDownload file, string progress = null)
336338 currentDownloadLastProgressUpdated = DateTime . UtcNow ;
337339 currentDownloadOLastTotalBytesReceived = currentDownloadBytesReceived ;
338340 }
339- Thread . Sleep ( 200 ) ;
341+ Thread . Sleep ( 150 ) ;
340342 }
343+ // webClient.Dispose();
341344 }
342- if ( ( File . Exists ( file . Path + file . FileName + ".dl" ) && String . Compare ( Tools . FileSHA256 ( file . Path + file . FileName + ".dl" ) , file . Sha256 , StringComparison . OrdinalIgnoreCase ) == 0 ) || ( File . Exists ( file . Path + file . FileName ) && String . Compare ( Tools . FileSHA256 ( file . Path + file . FileName ) , file . Sha256 , StringComparison . OrdinalIgnoreCase ) == 0 ) ) { return true ; }
345+ if ( ( File . Exists ( file . Path + file . FileName + ".dl" ) && Tools . FileSHA256 ( file . Path + file . FileName + ".dl" ) == file . Sha256 ) || ( File . Exists ( file . Path + file . FileName ) && Tools . FileSHA256 ( file . Path + file . FileName ) == file . Sha256 ) ) { return true ; } else { return false ; }
343346 }
344347 catch { }
345348 return false ;
@@ -392,6 +395,7 @@ private void WebClient_DownloadFileCompleted(object sender, System.ComponentMode
392395 ProgressDetails = "fail / error" ;
393396 downloaderTryesCount -- ;
394397 webClientTryesCount ++ ;
398+ currentDownloadBytesReceived = 0 ;
395399
396400 if ( webClientTryesCount > 2 )
397401 {
@@ -415,7 +419,7 @@ private void WebClient_DownloadProgressChanged(object sender, DownloadProgressCh
415419 {
416420 currentDownloadBytesReceived = e . BytesReceived ;
417421
418- if ( e . TotalBytesToReceive / 1024d > 100 ) // menos de 100kb não altera o progress para exibir o progresso
422+ if ( e . TotalBytesToReceive / 1024d > 50 ) // menos de 100kb não altera o progress para exibir o progresso
419423 {
420424 ProgressBar_Value = e . ProgressPercentage > 0 ? e . ProgressPercentage : 1 ;
421425
0 commit comments