aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--MediaBrowser.Api/UserLibrary/BaseItemsByNameService.cs4
-rw-r--r--MediaBrowser.Api/UserLibrary/YearsService.cs1
-rw-r--r--MediaBrowser.Controller/IServerApplicationHost.cs7
-rw-r--r--MediaBrowser.Server.Implementations/HttpServer/HttpServer.cs11
-rw-r--r--MediaBrowser.Server.Implementations/Sqlite/SQLiteRepository.cs45
-rw-r--r--MediaBrowser.ServerApplication/ApplicationHost.cs50
-rw-r--r--MediaBrowser.ServerApplication/EntryPoints/NewItemNotifier.cs4
-rw-r--r--MediaBrowser.ServerApplication/EntryPoints/WebSocketEvents.cs6
8 files changed, 68 insertions, 60 deletions
diff --git a/MediaBrowser.Api/UserLibrary/BaseItemsByNameService.cs b/MediaBrowser.Api/UserLibrary/BaseItemsByNameService.cs
index 293a9019e..0a2d6453a 100644
--- a/MediaBrowser.Api/UserLibrary/BaseItemsByNameService.cs
+++ b/MediaBrowser.Api/UserLibrary/BaseItemsByNameService.cs
@@ -1,12 +1,8 @@
using MediaBrowser.Controller.Dto;
using MediaBrowser.Controller.Entities;
-using MediaBrowser.Controller.Entities.Audio;
-using MediaBrowser.Controller.Entities.Movies;
-using MediaBrowser.Controller.Entities.TV;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Persistence;
using MediaBrowser.Model.Dto;
-using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Querying;
using ServiceStack.ServiceHost;
using System;
diff --git a/MediaBrowser.Api/UserLibrary/YearsService.cs b/MediaBrowser.Api/UserLibrary/YearsService.cs
index c7cd4ff24..b22a8dac3 100644
--- a/MediaBrowser.Api/UserLibrary/YearsService.cs
+++ b/MediaBrowser.Api/UserLibrary/YearsService.cs
@@ -2,7 +2,6 @@
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Persistence;
using ServiceStack.ServiceHost;
-using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
diff --git a/MediaBrowser.Controller/IServerApplicationHost.cs b/MediaBrowser.Controller/IServerApplicationHost.cs
index d64067f43..042ef30ec 100644
--- a/MediaBrowser.Controller/IServerApplicationHost.cs
+++ b/MediaBrowser.Controller/IServerApplicationHost.cs
@@ -3,8 +3,15 @@ using MediaBrowser.Model.System;
namespace MediaBrowser.Controller
{
+ /// <summary>
+ /// Interface IServerApplicationHost
+ /// </summary>
public interface IServerApplicationHost : IApplicationHost
{
+ /// <summary>
+ /// Gets the system info.
+ /// </summary>
+ /// <returns>SystemInfo.</returns>
SystemInfo GetSystemInfo();
}
}
diff --git a/MediaBrowser.Server.Implementations/HttpServer/HttpServer.cs b/MediaBrowser.Server.Implementations/HttpServer/HttpServer.cs
index 4f93f4b6e..01b867bdb 100644
--- a/MediaBrowser.Server.Implementations/HttpServer/HttpServer.cs
+++ b/MediaBrowser.Server.Implementations/HttpServer/HttpServer.cs
@@ -1,4 +1,3 @@
-using System.IO;
using Funq;
using MediaBrowser.Common;
using MediaBrowser.Common.Extensions;
@@ -17,6 +16,7 @@ using ServiceStack.WebHost.Endpoints.Support;
using System;
using System.Collections.Generic;
using System.Globalization;
+using System.IO;
using System.Linq;
using System.Net;
using System.Net.WebSockets;
@@ -498,6 +498,15 @@ namespace MediaBrowser.Server.Implementations.HttpServer
_logger.Info("Calling ServiceStack AppHost.Init");
Init();
}
+
+ /// <summary>
+ /// Releases the specified instance.
+ /// </summary>
+ /// <param name="instance">The instance.</param>
+ public override void Release(object instance)
+ {
+ // Leave this empty so SS doesn't try to dispose our objects
+ }
}
/// <summary>
diff --git a/MediaBrowser.Server.Implementations/Sqlite/SQLiteRepository.cs b/MediaBrowser.Server.Implementations/Sqlite/SQLiteRepository.cs
index 6824442f1..6179af1cb 100644
--- a/MediaBrowser.Server.Implementations/Sqlite/SQLiteRepository.cs
+++ b/MediaBrowser.Server.Implementations/Sqlite/SQLiteRepository.cs
@@ -160,27 +160,30 @@ namespace MediaBrowser.Server.Implementations.Sqlite
{
try
{
- if (connection != null)
+ lock (this)
{
- if (EnableDelayedCommands)
+ if (connection != null)
{
- FlushOnDispose();
+ if (EnableDelayedCommands)
+ {
+ FlushOnDispose();
+ }
+
+ if (connection.IsOpen())
+ {
+ connection.Close();
+ }
+
+ connection.Dispose();
+ connection = null;
}
-
- if (connection.IsOpen())
+
+ if (FlushTimer != null)
{
- connection.Close();
+ FlushTimer.Dispose();
+ FlushTimer = null;
}
-
- connection.Dispose();
- }
-
- if (FlushTimer != null)
- {
- FlushTimer.Dispose();
- FlushTimer = null;
}
-
}
catch (Exception ex)
{
@@ -195,13 +198,13 @@ namespace MediaBrowser.Server.Implementations.Sqlite
private void FlushOnDispose()
{
// If we're not already flushing, do it now
- if (!IsFlushing)
+ if (!_isFlushing)
{
Flush(null);
}
// Don't dispose in the middle of a flush
- while (IsFlushing)
+ while (_isFlushing)
{
Thread.Sleep(25);
}
@@ -225,7 +228,7 @@ namespace MediaBrowser.Server.Implementations.Sqlite
/// <summary>
/// The is flushing
/// </summary>
- private bool IsFlushing;
+ private bool _isFlushing;
/// <summary>
/// Flushes the specified sender.
@@ -241,12 +244,12 @@ namespace MediaBrowser.Server.Implementations.Sqlite
return;
}
- if (IsFlushing)
+ if (_isFlushing)
{
return;
}
- IsFlushing = true;
+ _isFlushing = true;
var numCommands = 0;
using (var tran = connection.BeginTransaction())
@@ -278,7 +281,7 @@ namespace MediaBrowser.Server.Implementations.Sqlite
Logger.Debug("SQL Delayed writer executed " + numCommands + " commands");
FlushTimer.Change(TimeSpan.FromMilliseconds(FlushInterval), TimeSpan.FromMilliseconds(-1));
- IsFlushing = false;
+ _isFlushing = false;
}
/// <summary>
diff --git a/MediaBrowser.ServerApplication/ApplicationHost.cs b/MediaBrowser.ServerApplication/ApplicationHost.cs
index 94a06020e..18916e99e 100644
--- a/MediaBrowser.ServerApplication/ApplicationHost.cs
+++ b/MediaBrowser.ServerApplication/ApplicationHost.cs
@@ -159,6 +159,9 @@ namespace MediaBrowser.ServerApplication
/// </summary>
/// <value>The user data repository.</value>
private IUserDataRepository UserDataRepository { get; set; }
+ private IUserRepository UserRepository { get; set; }
+ private IDisplayPreferencesRepository DisplayPreferencesRepository { get; set; }
+ private IItemRepository ItemRepository { get; set; }
/// <summary>
/// The full path to our startmenu shortcut
@@ -239,6 +242,15 @@ namespace MediaBrowser.ServerApplication
UserDataRepository = new SQLiteUserDataRepository(ApplicationPaths, JsonSerializer, LogManager);
RegisterSingleInstance(UserDataRepository);
+ UserRepository = new SQLiteUserRepository(ApplicationPaths, JsonSerializer, LogManager);
+ RegisterSingleInstance(UserRepository);
+
+ DisplayPreferencesRepository = new SQLiteDisplayPreferencesRepository(ApplicationPaths, JsonSerializer, LogManager);
+ RegisterSingleInstance(DisplayPreferencesRepository);
+
+ ItemRepository = new SQLiteItemRepository(ApplicationPaths, JsonSerializer, LogManager);
+ RegisterSingleInstance(ItemRepository);
+
UserManager = new UserManager(Logger, ServerConfigurationManager, UserDataRepository);
RegisterSingleInstance(UserManager);
@@ -299,11 +311,9 @@ namespace MediaBrowser.ServerApplication
/// <returns>Task.</returns>
private async Task ConfigureDisplayPreferencesRepositories()
{
- var repository = new SQLiteDisplayPreferencesRepository(ApplicationPaths, JsonSerializer, LogManager);
-
- await repository.Initialize().ConfigureAwait(false);
+ await DisplayPreferencesRepository.Initialize().ConfigureAwait(false);
- ((DisplayPreferencesManager)DisplayPreferencesManager).Repository = repository;
+ ((DisplayPreferencesManager)DisplayPreferencesManager).Repository = DisplayPreferencesRepository;
}
/// <summary>
@@ -312,11 +322,9 @@ namespace MediaBrowser.ServerApplication
/// <returns>Task.</returns>
private async Task ConfigureItemRepositories()
{
- var repository = new SQLiteItemRepository(ApplicationPaths, JsonSerializer, LogManager);
+ await ItemRepository.Initialize().ConfigureAwait(false);
- await repository.Initialize().ConfigureAwait(false);
-
- ((LibraryManager)LibraryManager).ItemRepository = repository;
+ ((LibraryManager)LibraryManager).ItemRepository = ItemRepository;
}
/// <summary>
@@ -328,13 +336,15 @@ namespace MediaBrowser.ServerApplication
return UserDataRepository.Initialize();
}
+ /// <summary>
+ /// Configures the user repositories.
+ /// </summary>
+ /// <returns>Task.</returns>
private async Task ConfigureUserRepositories()
{
- var repository = new SQLiteUserRepository(ApplicationPaths, JsonSerializer, LogManager);
+ await UserRepository.Initialize().ConfigureAwait(false);
- await repository.Initialize().ConfigureAwait(false);
-
- ((UserManager)UserManager).UserRepository = repository;
+ ((UserManager)UserManager).UserRepository = UserRepository;
}
/// <summary>
@@ -553,21 +563,5 @@ namespace MediaBrowser.ServerApplication
process.WaitForExit();
}
}
-
- /// <summary>
- /// Gets the repository.
- /// </summary>
- /// <typeparam name="T"></typeparam>
- /// <param name="repositories">The repositories.</param>
- /// <param name="name">The name.</param>
- /// <returns>``0.</returns>
- private T GetRepository<T>(IEnumerable<T> repositories, string name)
- where T : class, IRepository
- {
- var enumerable = repositories as T[] ?? repositories.ToArray();
-
- return enumerable.FirstOrDefault(r => string.Equals(r.Name, name, StringComparison.OrdinalIgnoreCase)) ??
- enumerable.FirstOrDefault();
- }
}
}
diff --git a/MediaBrowser.ServerApplication/EntryPoints/NewItemNotifier.cs b/MediaBrowser.ServerApplication/EntryPoints/NewItemNotifier.cs
index ae898f0f9..bf4eb6e91 100644
--- a/MediaBrowser.ServerApplication/EntryPoints/NewItemNotifier.cs
+++ b/MediaBrowser.ServerApplication/EntryPoints/NewItemNotifier.cs
@@ -1,5 +1,4 @@
-using System.Windows;
-using MediaBrowser.Controller.Entities;
+using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Plugins;
using MediaBrowser.Model.Logging;
@@ -7,6 +6,7 @@ using MediaBrowser.ServerApplication.Controls;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
+using System.Windows;
using System.Windows.Controls.Primitives;
namespace MediaBrowser.ServerApplication.EntryPoints
diff --git a/MediaBrowser.ServerApplication/EntryPoints/WebSocketEvents.cs b/MediaBrowser.ServerApplication/EntryPoints/WebSocketEvents.cs
index 056e50a78..a6d505d19 100644
--- a/MediaBrowser.ServerApplication/EntryPoints/WebSocketEvents.cs
+++ b/MediaBrowser.ServerApplication/EntryPoints/WebSocketEvents.cs
@@ -1,6 +1,4 @@
-using System.Linq;
-using System.Threading;
-using MediaBrowser.Common.Events;
+using MediaBrowser.Common.Events;
using MediaBrowser.Common.Net;
using MediaBrowser.Common.Plugins;
using MediaBrowser.Common.ScheduledTasks;
@@ -15,6 +13,8 @@ using MediaBrowser.Model.Logging;
using MediaBrowser.Model.Tasks;
using MediaBrowser.Model.Updates;
using System;
+using System.Linq;
+using System.Threading;
namespace MediaBrowser.ServerApplication.EntryPoints
{