diff options
| author | LukePulverenti <luke.pulverenti@gmail.com> | 2013-03-02 18:27:12 -0500 |
|---|---|---|
| committer | LukePulverenti <luke.pulverenti@gmail.com> | 2013-03-02 18:27:12 -0500 |
| commit | 71fe785c6de047a09f6f585fd407332e73415f0e (patch) | |
| tree | 6680b7ab819bf23f1cad3c833147213a131f7991 | |
| parent | f4f5d31cdec444e3a3fa244581e79251db5e7432 (diff) | |
| parent | 60662a0f165d1cf4c271c95f00b57fc484ab75e3 (diff) | |
Merge branch 'master' of https://github.com/MediaBrowser/MediaBrowser
| -rw-r--r-- | MediaBrowser.Common.Implementations/BaseApplicationPaths.cs | 5 | ||||
| -rw-r--r-- | MediaBrowser.Common/Constants/Constants.cs | 2 | ||||
| -rw-r--r-- | MediaBrowser.Common/Kernel/IApplicationPaths.cs | 6 | ||||
| -rw-r--r-- | MediaBrowser.Common/MediaBrowser.Common.csproj | 1 | ||||
| -rw-r--r-- | MediaBrowser.Common/Updates/ApplicationUpdater.cs | 37 | ||||
| -rw-r--r-- | MediaBrowser.ServerApplication/App.xaml.cs | 24 | ||||
| -rw-r--r-- | MediaBrowser.ServerApplication/ApplicationHost.cs | 3 | ||||
| -rw-r--r-- | MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj | 1 | ||||
| -rw-r--r-- | MediaBrowser.sln | 3 |
9 files changed, 77 insertions, 5 deletions
diff --git a/MediaBrowser.Common.Implementations/BaseApplicationPaths.cs b/MediaBrowser.Common.Implementations/BaseApplicationPaths.cs index d94d79c75..37bd62200 100644 --- a/MediaBrowser.Common.Implementations/BaseApplicationPaths.cs +++ b/MediaBrowser.Common.Implementations/BaseApplicationPaths.cs @@ -43,6 +43,11 @@ namespace MediaBrowser.Common.Implementations } /// <summary> + /// Gets the path to the system folder + /// </summary> + public string ProgramSystemPath { get { return Path.Combine(ProgramDataPath, "System"); }} + + /// <summary> /// The _data directory /// </summary> private string _dataDirectory; diff --git a/MediaBrowser.Common/Constants/Constants.cs b/MediaBrowser.Common/Constants/Constants.cs index 676518737..c1c79d199 100644 --- a/MediaBrowser.Common/Constants/Constants.cs +++ b/MediaBrowser.Common/Constants/Constants.cs @@ -9,5 +9,7 @@ namespace MediaBrowser.Common.Constants public static class Constants { public const string MBAdminUrl = "http://www.mb3admin.com/admin/"; + public const string MBServerPkgName = "MBServer"; + public const string MBTheaterPkgName = "MBTheater"; } } diff --git a/MediaBrowser.Common/Kernel/IApplicationPaths.cs b/MediaBrowser.Common/Kernel/IApplicationPaths.cs index abb783642..52c3b199d 100644 --- a/MediaBrowser.Common/Kernel/IApplicationPaths.cs +++ b/MediaBrowser.Common/Kernel/IApplicationPaths.cs @@ -13,6 +13,12 @@ namespace MediaBrowser.Common.Kernel string ProgramDataPath { get; } /// <summary> + /// Gets the path to the program system folder + /// </summary> + /// <value>The program data path.</value> + string ProgramSystemPath { get; } + + /// <summary> /// Gets the folder path to the data directory /// </summary> /// <value>The data directory.</value> diff --git a/MediaBrowser.Common/MediaBrowser.Common.csproj b/MediaBrowser.Common/MediaBrowser.Common.csproj index d2bfcc38f..284649b53 100644 --- a/MediaBrowser.Common/MediaBrowser.Common.csproj +++ b/MediaBrowser.Common/MediaBrowser.Common.csproj @@ -104,6 +104,7 @@ <Compile Include="ScheduledTasks\IntervalTrigger.cs" /> <Compile Include="ScheduledTasks\WeeklyTrigger.cs" /> <Compile Include="Security\ISecurityManager.cs" /> + <Compile Include="Updates\ApplicationUpdater.cs" /> <Compile Include="Updates\IPackageManager.cs" /> </ItemGroup> <ItemGroup> diff --git a/MediaBrowser.Common/Updates/ApplicationUpdater.cs b/MediaBrowser.Common/Updates/ApplicationUpdater.cs new file mode 100644 index 000000000..e157c344b --- /dev/null +++ b/MediaBrowser.Common/Updates/ApplicationUpdater.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.IO; +using MediaBrowser.Common.Kernel; + +namespace MediaBrowser.Common.Updates +{ + public enum MBApplication + { + MBServer, + MBTheater + } + + /// <summary> + /// Update the specified application using the specified archive + /// </summary> + public class ApplicationUpdater + { + private const string UpdaterExe = "Mediabrowser.Installer.exe"; + public void UpdateApplication(MBApplication app, IApplicationPaths appPaths, string archive) + { + // Use our installer passing it the specific archive + // We need to copy to a temp directory and execute it there + var source = Path.Combine(appPaths.ProgramSystemPath, UpdaterExe); + var target = Path.Combine(Path.GetTempPath(), UpdaterExe); + var product = app == MBApplication.MBTheater ? "mbt" : "server"; + File.Copy(source, target, true); + Process.Start(UpdaterExe, string.Format("product={0} archive=\"{1}\" caller={2}", product, archive, Process.GetCurrentProcess().Id)); + + // That's it. The installer will do the work once we exit + } + } +} diff --git a/MediaBrowser.ServerApplication/App.xaml.cs b/MediaBrowser.ServerApplication/App.xaml.cs index e9baa96e7..dddd87782 100644 --- a/MediaBrowser.ServerApplication/App.xaml.cs +++ b/MediaBrowser.ServerApplication/App.xaml.cs @@ -1,8 +1,11 @@ -using MediaBrowser.ClickOnce; +using System.IO; +using MediaBrowser.Common.Constants; using MediaBrowser.Common.Kernel; +using MediaBrowser.Common.Updates; using MediaBrowser.Controller; using MediaBrowser.Controller.Entities; using MediaBrowser.Model.Logging; +using MediaBrowser.Server.Implementations; using Microsoft.Win32; using System; using System.Diagnostics; @@ -27,6 +30,25 @@ namespace MediaBrowser.ServerApplication [STAThread] public static void Main() { + // Look for the existence of an update archive + var appPaths = new ServerApplicationPaths(); + var updateArchive = Path.Combine(appPaths.TempUpdatePath, Constants.MBServerPkgName + ".zip"); + if (File.Exists(updateArchive)) + { + // Update is there - execute update + try + { + new ApplicationUpdater().UpdateApplication(MBApplication.MBServer, appPaths, updateArchive); + + // And just let the app exit so it can update + return; + } + catch (Exception e) + { + MessageBox.Show(string.Format("Error attempting to update application.\n\n{0}\n\n{1}", e.GetType().Name, e.Message)); + } + } + var application = new App(); application.Run(); diff --git a/MediaBrowser.ServerApplication/ApplicationHost.cs b/MediaBrowser.ServerApplication/ApplicationHost.cs index ce4aa5ebd..6c39d0b6b 100644 --- a/MediaBrowser.ServerApplication/ApplicationHost.cs +++ b/MediaBrowser.ServerApplication/ApplicationHost.cs @@ -1,4 +1,5 @@ using MediaBrowser.Api; +using MediaBrowser.Common.Constants; using MediaBrowser.Common.Implementations; using MediaBrowser.Common.Implementations.HttpServer; using MediaBrowser.Common.Implementations.Logging; @@ -180,7 +181,7 @@ namespace MediaBrowser.ServerApplication { var pkgManager = Resolve<IPackageManager>(); var availablePackages = await pkgManager.GetAvailablePackages(Resolve<IHttpClient>(), Resolve<INetworkManager>(), Kernel.SecurityManager, Kernel.ResourcePools, Resolve<IJsonSerializer>(), CancellationToken.None).ConfigureAwait(false); - var version = Kernel.InstallationManager.GetLatestCompatibleVersion(availablePackages, "MBServer", Kernel.Configuration.SystemUpdateLevel); + var version = Kernel.InstallationManager.GetLatestCompatibleVersion(availablePackages, Constants.MBServerPkgName, Kernel.Configuration.SystemUpdateLevel); return version != null ? new CheckForUpdateResult { AvailableVersion = version.version, IsUpdateAvailable = version.version > ApplicationVersion, Package = version } : new CheckForUpdateResult { AvailableVersion = ApplicationVersion, IsUpdateAvailable = false }; diff --git a/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj b/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj index 16c657097..158fc0560 100644 --- a/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj +++ b/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj @@ -375,6 +375,7 @@ xcopy "$(SolutionDir)Mediabrowser.Uninstaller\bin\Release\MediaBrowser.Uninstall xcopy "$(SolutionDir)Mediabrowser.Uninstaller.Execute\bin\Release\MediaBrowser.Uninstaller.Execute.exe.config" "$(SolutionDir)..\Deploy\Server\System\" /y xcopy "$(SolutionDir)Mediabrowser.Uninstaller\bin\Release\MediaBrowser.Uninstaller.exe" "$(SolutionDir)..\Deploy\Server\System\" /y xcopy "$(SolutionDir)Mediabrowser.Uninstaller.Execute\bin\Release\MediaBrowser.Uninstaller.Execute.exe" "$(SolutionDir)..\Deploy\Server\System\" /y +xcopy "$(SolutionDir)Mediabrowser.Installer\bin\Release\MediaBrowser.Installer.exe" "$(SolutionDir)..\Deploy\Server\System\" /y xcopy "$(TargetDir)$(TargetFileName).config" "$(SolutionDir)..\Deploy\Server\System\" /y diff --git a/MediaBrowser.sln b/MediaBrowser.sln index 0fe54d005..b473b2062 100644 --- a/MediaBrowser.sln +++ b/MediaBrowser.sln @@ -253,7 +253,4 @@ Global GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection - GlobalSection(Performance) = preSolution - HasPerformanceSessions = true - EndGlobalSection EndGlobal |
