mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-11-16 18:42:52 -07:00
Implement retries on package download in installer
This commit is contained in:
parent
178859e0bd
commit
ce014b1f14
@ -4,6 +4,7 @@ using System.Configuration;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Linq;
|
||||
@ -336,15 +337,21 @@ namespace MediaBrowser.Installer
|
||||
/// <returns>The fully qualified name of the downloaded package</returns>
|
||||
protected async Task<string> DownloadPackage(PackageVersionInfo version)
|
||||
{
|
||||
var success = false;
|
||||
var retryCount = 0;
|
||||
var archiveFile = Path.Combine(PrepareTempLocation(), version.targetFilename);
|
||||
|
||||
try
|
||||
{
|
||||
var archiveFile = Path.Combine(PrepareTempLocation(), version.targetFilename);
|
||||
while (!success && retryCount < 3)
|
||||
{
|
||||
|
||||
// setup download progress and download the package
|
||||
MainClient.DownloadProgressChanged += DownloadProgressChanged;
|
||||
try
|
||||
{
|
||||
await MainClient.DownloadFileTaskAsync(version.sourceUrl, archiveFile);
|
||||
success = true;
|
||||
}
|
||||
catch (WebException e)
|
||||
{
|
||||
@ -352,8 +359,18 @@ namespace MediaBrowser.Installer
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if (e.Status == WebExceptionStatus.Timeout || e.Status == WebExceptionStatus.ConnectFailure || e.Status == WebExceptionStatus.ProtocolError)
|
||||
{
|
||||
Thread.Sleep(500); //wait just a sec
|
||||
PrepareTempLocation(); //clear this out
|
||||
retryCount++;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return archiveFile;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user