mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-09-06 19:37:55 +02:00
Merge branch 'master' of https://github.com/MediaBrowser/MediaBrowser
This commit is contained in:
commit
4435e83e69
1 changed files with 46 additions and 27 deletions
|
@ -30,6 +30,8 @@ namespace MediaBrowser.Installer
|
||||||
|
|
||||||
protected string TempLocation = Path.Combine(Path.GetTempPath(), "MediaBrowser");
|
protected string TempLocation = Path.Combine(Path.GetTempPath(), "MediaBrowser");
|
||||||
|
|
||||||
|
protected WebClient MainClient = new WebClient();
|
||||||
|
|
||||||
public MainWindow()
|
public MainWindow()
|
||||||
{
|
{
|
||||||
GetArgs();
|
GetArgs();
|
||||||
|
@ -48,6 +50,15 @@ namespace MediaBrowser.Installer
|
||||||
{
|
{
|
||||||
e.Cancel = true;
|
e.Cancel = true;
|
||||||
}
|
}
|
||||||
|
if (MainClient.IsBusy)
|
||||||
|
{
|
||||||
|
MainClient.CancelAsync();
|
||||||
|
while (MainClient.IsBusy)
|
||||||
|
{
|
||||||
|
// wait to finish
|
||||||
|
}
|
||||||
|
}
|
||||||
|
MainClient.Dispose();
|
||||||
ClearTempLocation(TempLocation);
|
ClearTempLocation(TempLocation);
|
||||||
base.OnClosing(e);
|
base.OnClosing(e);
|
||||||
}
|
}
|
||||||
|
@ -129,6 +140,8 @@ namespace MediaBrowser.Installer
|
||||||
dlAnimation.StopAnimation();
|
dlAnimation.StopAnimation();
|
||||||
prgProgress.Visibility = btnCancel.Visibility = Visibility.Hidden;
|
prgProgress.Visibility = btnCancel.Visibility = Visibility.Hidden;
|
||||||
|
|
||||||
|
if (archive == null) return; //we canceled or had an error that was already reported
|
||||||
|
|
||||||
// Extract
|
// Extract
|
||||||
lblStatus.Content = "Extracting Package...";
|
lblStatus.Content = "Extracting Package...";
|
||||||
try
|
try
|
||||||
|
@ -166,13 +179,11 @@ namespace MediaBrowser.Installer
|
||||||
}
|
}
|
||||||
|
|
||||||
protected async Task<PackageVersionInfo> GetPackageVersion()
|
protected async Task<PackageVersionInfo> GetPackageVersion()
|
||||||
{
|
|
||||||
using (var client = new WebClient())
|
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// get the package information for the server
|
// get the package information for the server
|
||||||
var json = await client.DownloadStringTaskAsync("http://www.mb3admin.com/admin/service/package/retrieveAll?name=" + PackageName);
|
var json = await MainClient.DownloadStringTaskAsync("http://www.mb3admin.com/admin/service/package/retrieveAll?name=" + PackageName);
|
||||||
var packages = JsonSerializer.DeserializeFromString<List<PackageInfo>>(json);
|
var packages = JsonSerializer.DeserializeFromString<List<PackageInfo>>(json);
|
||||||
|
|
||||||
var version = packages[0].versions.Where(v => v.classification <= PackageClass).OrderByDescending(v => v.version).FirstOrDefault(v => v.version <= PackageVersion);
|
var version = packages[0].versions.Where(v => v.classification <= PackageClass).OrderByDescending(v => v.version).FirstOrDefault(v => v.version <= PackageVersion);
|
||||||
|
@ -188,7 +199,6 @@ namespace MediaBrowser.Installer
|
||||||
SystemClose(e.GetType().FullName + "\n\n" + e.Message);
|
SystemClose(e.GetType().FullName + "\n\n" + e.Message);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -197,23 +207,32 @@ namespace MediaBrowser.Installer
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>The fully qualified name of the downloaded package</returns>
|
/// <returns>The fully qualified name of the downloaded package</returns>
|
||||||
protected async Task<string> DownloadPackage(PackageVersionInfo version)
|
protected async Task<string> DownloadPackage(PackageVersionInfo version)
|
||||||
{
|
|
||||||
using (var client = new WebClient())
|
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var archiveFile = Path.Combine(PrepareTempLocation(), version.targetFilename);
|
var archiveFile = Path.Combine(PrepareTempLocation(), version.targetFilename);
|
||||||
|
|
||||||
// setup download progress and download the package
|
// setup download progress and download the package
|
||||||
client.DownloadProgressChanged += DownloadProgressChanged;
|
MainClient.DownloadProgressChanged += DownloadProgressChanged;
|
||||||
await client.DownloadFileTaskAsync(version.sourceUrl, archiveFile);
|
try
|
||||||
|
{
|
||||||
|
await MainClient.DownloadFileTaskAsync(version.sourceUrl, archiveFile);
|
||||||
|
}
|
||||||
|
catch (WebException e)
|
||||||
|
{
|
||||||
|
if (e.Status == WebExceptionStatus.RequestCanceled)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
|
||||||
return archiveFile;
|
return archiveFile;
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
SystemClose(e.GetType().FullName + "\n\n" + e.Message);
|
SystemClose(e.GetType().FullName + "\n\n" + e.Message);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return "";
|
return "";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue