|
|
|
@ -24,6 +24,7 @@ namespace MediaBrowser.Installer
|
|
|
|
|
protected string RootSuffix = "-Server";
|
|
|
|
|
protected string TargetExe = "MediaBrowser.ServerApplication.exe";
|
|
|
|
|
protected string FriendlyName = "Media Browser Server";
|
|
|
|
|
protected string Archive = null;
|
|
|
|
|
protected string RootPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "MediaBrowser-Server");
|
|
|
|
|
|
|
|
|
|
protected bool SystemClosing = false;
|
|
|
|
@ -36,7 +37,7 @@ namespace MediaBrowser.Installer
|
|
|
|
|
{
|
|
|
|
|
GetArgs();
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
DoInstall();
|
|
|
|
|
DoInstall(Archive);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void btnCancel_Click(object sender, RoutedEventArgs e)
|
|
|
|
@ -77,6 +78,8 @@ namespace MediaBrowser.Installer
|
|
|
|
|
{
|
|
|
|
|
var product = ConfigurationManager.AppSettings["product"] ?? "server";
|
|
|
|
|
PackageClass = (PackageVersionClass) Enum.Parse(typeof (PackageVersionClass), ConfigurationManager.AppSettings["class"] ?? "Release");
|
|
|
|
|
var cmdArgs = Environment.GetCommandLineArgs();
|
|
|
|
|
Archive = cmdArgs.Length > 1 ? cmdArgs[1] : null;
|
|
|
|
|
|
|
|
|
|
switch (product.ToLower())
|
|
|
|
|
{
|
|
|
|
@ -103,7 +106,7 @@ namespace MediaBrowser.Installer
|
|
|
|
|
/// Execute the install process
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
protected async Task DoInstall()
|
|
|
|
|
protected async Task DoInstall(string archive)
|
|
|
|
|
{
|
|
|
|
|
lblStatus.Text = string.Format("Downloading {0}...", FriendlyName);
|
|
|
|
|
|
|
|
|
@ -150,16 +153,18 @@ namespace MediaBrowser.Installer
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Download
|
|
|
|
|
string archive = null;
|
|
|
|
|
lblStatus.Text = string.Format("Downloading {0} (version {1})...", FriendlyName, version.versionStr);
|
|
|
|
|
try
|
|
|
|
|
// Download if we don't already have it
|
|
|
|
|
if (archive == null)
|
|
|
|
|
{
|
|
|
|
|
archive = await DownloadPackage(version);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|
SystemClose("Error Downloading Package - " + e.GetType().FullName + "\n\n" + e.Message);
|
|
|
|
|
lblStatus.Text = string.Format("Downloading {0} (version {1})...", FriendlyName, version.versionStr);
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
archive = await DownloadPackage(version);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|
SystemClose("Error Downloading Package - " + e.GetType().FullName + "\n\n" + e.Message);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (archive == null) return; //we canceled or had an error that was already reported
|
|
|
|
@ -274,7 +279,9 @@ namespace MediaBrowser.Installer
|
|
|
|
|
// Delete old content of system
|
|
|
|
|
var systemDir = Path.Combine(RootPath, "system");
|
|
|
|
|
if (Directory.Exists(systemDir)) Directory.Delete(systemDir, true);
|
|
|
|
|
using (var fileStream = System.IO.File.OpenRead(archive))
|
|
|
|
|
|
|
|
|
|
// And extract
|
|
|
|
|
using (var fileStream = File.OpenRead(archive))
|
|
|
|
|
{
|
|
|
|
|
using (var zipFile = ZipFile.Read(fileStream))
|
|
|
|
|
{
|
|
|
|
|