| 
														
															@@ -28,43 +28,10 @@ namespace Emby.Server.Implementations.Updates 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     /// </summary> 
														 | 
														
														 | 
														
															     /// </summary> 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     public class InstallationManager : IInstallationManager 
														 | 
														
														 | 
														
															     public class InstallationManager : IInstallationManager 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     { 
														 | 
														
														 | 
														
															     { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        public event EventHandler<InstallationEventArgs> PackageInstalling; 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        public event EventHandler<InstallationEventArgs> PackageInstallationCompleted; 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        public event EventHandler<InstallationFailedEventArgs> PackageInstallationFailed; 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        public event EventHandler<InstallationEventArgs> PackageInstallationCancelled; 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															- 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        /// <summary> 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        /// The current installations 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        /// </summary> 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        private List<(InstallationInfo info, CancellationTokenSource token)> _currentInstallations { get; set; } 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															- 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        /// <summary> 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        /// The completed installations 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        /// </summary> 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        private ConcurrentBag<InstallationInfo> _completedInstallationsInternal; 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															- 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        public IEnumerable<InstallationInfo> CompletedInstallations => _completedInstallationsInternal; 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															- 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        /// <summary> 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        /// Occurs when [plugin uninstalled]. 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        /// </summary> 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        public event EventHandler<GenericEventArgs<IPlugin>> PluginUninstalled; 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															- 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        /// <summary> 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        /// Occurs when [plugin updated]. 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        /// </summary> 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        public event EventHandler<GenericEventArgs<(IPlugin, PackageVersionInfo)>> PluginUpdated; 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															- 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         /// <summary> 
														 | 
														
														 | 
														
															         /// <summary> 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        /// Occurs when [plugin updated]. 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        /// </summary> 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        public event EventHandler<GenericEventArgs<PackageVersionInfo>> PluginInstalled; 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															- 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        /// <summary> 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        /// The _logger 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        /// The _logger. 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         /// </summary> 
														 | 
														
														 | 
														
															         /// </summary> 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         private readonly ILogger _logger; 
														 | 
														
														 | 
														
															         private readonly ILogger _logger; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															- 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         private readonly IApplicationPaths _appPaths; 
														 | 
														
														 | 
														
															         private readonly IApplicationPaths _appPaths; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         private readonly IHttpClient _httpClient; 
														 | 
														
														 | 
														
															         private readonly IHttpClient _httpClient; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         private readonly IJsonSerializer _jsonSerializer; 
														 | 
														
														 | 
														
															         private readonly IJsonSerializer _jsonSerializer; 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -79,6 +46,18 @@ namespace Emby.Server.Implementations.Updates 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															         private readonly IZipClient _zipClient; 
														 | 
														
														 | 
														
															         private readonly IZipClient _zipClient; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        private readonly object _currentInstallationsLock = new object(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        /// <summary> 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        /// The current installations. 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        /// </summary> 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        private List<(InstallationInfo info, CancellationTokenSource token)> _currentInstallations; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        /// <summary> 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        /// The completed installations. 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        /// </summary> 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        private ConcurrentBag<InstallationInfo> _completedInstallationsInternal; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         public InstallationManager( 
														 | 
														
														 | 
														
															         public InstallationManager( 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             ILogger<InstallationManager> logger, 
														 | 
														
														 | 
														
															             ILogger<InstallationManager> logger, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             IApplicationHost appHost, 
														 | 
														
														 | 
														
															             IApplicationHost appHost, 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -107,6 +86,31 @@ namespace Emby.Server.Implementations.Updates 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             _zipClient = zipClient; 
														 | 
														
														 | 
														
															             _zipClient = zipClient; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         } 
														 | 
														
														 | 
														
															         } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        public event EventHandler<InstallationEventArgs> PackageInstalling; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        public event EventHandler<InstallationEventArgs> PackageInstallationCompleted; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        public event EventHandler<InstallationFailedEventArgs> PackageInstallationFailed; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        public event EventHandler<InstallationEventArgs> PackageInstallationCancelled; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        /// <summary> 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        /// Occurs when [plugin uninstalled]. 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        /// </summary> 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        public event EventHandler<GenericEventArgs<IPlugin>> PluginUninstalled; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        /// <summary> 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        /// Occurs when [plugin updated]. 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        /// </summary> 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        public event EventHandler<GenericEventArgs<(IPlugin, PackageVersionInfo)>> PluginUpdated; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        /// <summary> 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        /// Occurs when [plugin updated]. 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        /// </summary> 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        public event EventHandler<GenericEventArgs<PackageVersionInfo>> PluginInstalled; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        public IEnumerable<InstallationInfo> CompletedInstallations => _completedInstallationsInternal; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         /// <summary> 
														 | 
														
														 | 
														
															         /// <summary> 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         /// Gets all available packages. 
														 | 
														
														 | 
														
															         /// Gets all available packages. 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         /// </summary> 
														 | 
														
														 | 
														
															         /// </summary> 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -330,7 +334,7 @@ namespace Emby.Server.Implementations.Updates 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             var tuple = (installationInfo, innerCancellationTokenSource); 
														 | 
														
														 | 
														
															             var tuple = (installationInfo, innerCancellationTokenSource); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															             // Add it to the in-progress list 
														 | 
														
														 | 
														
															             // Add it to the in-progress list 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            lock (_currentInstallations) 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            lock (_currentInstallationsLock) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             { 
														 | 
														
														 | 
														
															             { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															                 _currentInstallations.Add(tuple); 
														 | 
														
														 | 
														
															                 _currentInstallations.Add(tuple); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             } 
														 | 
														
														 | 
														
															             } 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -349,7 +353,7 @@ namespace Emby.Server.Implementations.Updates 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             { 
														 | 
														
														 | 
														
															             { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															                 await InstallPackageInternal(package, linkedToken).ConfigureAwait(false); 
														 | 
														
														 | 
														
															                 await InstallPackageInternal(package, linkedToken).ConfigureAwait(false); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                lock (_currentInstallations) 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                lock (_currentInstallationsLock) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															                 { 
														 | 
														
														 | 
														
															                 { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															                     _currentInstallations.Remove(tuple); 
														 | 
														
														 | 
														
															                     _currentInstallations.Remove(tuple); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															                 } 
														 | 
														
														 | 
														
															                 } 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -360,7 +364,7 @@ namespace Emby.Server.Implementations.Updates 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             } 
														 | 
														
														 | 
														
															             } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             catch (OperationCanceledException) 
														 | 
														
														 | 
														
															             catch (OperationCanceledException) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             { 
														 | 
														
														 | 
														
															             { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                lock (_currentInstallations) 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                lock (_currentInstallationsLock) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															                 { 
														 | 
														
														 | 
														
															                 { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															                     _currentInstallations.Remove(tuple); 
														 | 
														
														 | 
														
															                     _currentInstallations.Remove(tuple); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															                 } 
														 | 
														
														 | 
														
															                 } 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -375,7 +379,7 @@ namespace Emby.Server.Implementations.Updates 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             { 
														 | 
														
														 | 
														
															             { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															                 _logger.LogError(ex, "Package installation failed"); 
														 | 
														
														 | 
														
															                 _logger.LogError(ex, "Package installation failed"); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                lock (_currentInstallations) 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                lock (_currentInstallationsLock) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															                 { 
														 | 
														
														 | 
														
															                 { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															                     _currentInstallations.Remove(tuple); 
														 | 
														
														 | 
														
															                     _currentInstallations.Remove(tuple); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															                 } 
														 | 
														
														 | 
														
															                 } 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -535,7 +539,7 @@ namespace Emby.Server.Implementations.Updates 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         /// <inheritdoc/> 
														 | 
														
														 | 
														
															         /// <inheritdoc/> 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         public bool CancelInstallation(Guid id) 
														 | 
														
														 | 
														
															         public bool CancelInstallation(Guid id) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         { 
														 | 
														
														 | 
														
															         { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            lock (_currentInstallations) 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            lock (_currentInstallationsLock) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             { 
														 | 
														
														 | 
														
															             { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															                 var install = _currentInstallations.Find(x => x.Item1.Id == id); 
														 | 
														
														 | 
														
															                 var install = _currentInstallations.Find(x => x.Item1.Id == id); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															                 if (install == default((InstallationInfo, CancellationTokenSource))) 
														 | 
														
														 | 
														
															                 if (install == default((InstallationInfo, CancellationTokenSource))) 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -563,7 +567,7 @@ namespace Emby.Server.Implementations.Updates 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         { 
														 | 
														
														 | 
														
															         { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             if (dispose) 
														 | 
														
														 | 
														
															             if (dispose) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             { 
														 | 
														
														 | 
														
															             { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                lock (_currentInstallations) 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                lock (_currentInstallationsLock) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															                 { 
														 | 
														
														 | 
														
															                 { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															                     foreach (var tuple in _currentInstallations) 
														 | 
														
														 | 
														
															                     foreach (var tuple in _currentInstallations) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															                     { 
														 | 
														
														 | 
														
															                     { 
														 |