diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2013-09-26 17:20:26 -0400 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2013-09-26 17:20:26 -0400 |
| commit | 2d8152f36ad8ecc5674cfb25ad328d3e671a22de (patch) | |
| tree | 3adc6e475d7375141af11acb80714114a5fab931 /MediaBrowser.Server.Implementations | |
| parent | 2d0cc66e6bea278b7be5078130f55fc05ce756ce (diff) | |
mono progress - able to start app
Diffstat (limited to 'MediaBrowser.Server.Implementations')
3 files changed, 25 insertions, 12 deletions
diff --git a/MediaBrowser.Server.Implementations/Dto/DtoService.cs b/MediaBrowser.Server.Implementations/Dto/DtoService.cs index a5f54b938..740f5fbbc 100644 --- a/MediaBrowser.Server.Implementations/Dto/DtoService.cs +++ b/MediaBrowser.Server.Implementations/Dto/DtoService.cs @@ -1074,7 +1074,7 @@ namespace MediaBrowser.Server.Implementations.Dto double totalPercentPlayed = 0; // Loop through each recursive child - foreach (var child in folder.GetRecursiveChildren(user, true).Where(i => !i.IsFolder).ToList()) + foreach (var child in folder.GetRecursiveChildren(user, i => !i.IsFolder)) { var userdata = _userDataRepository.GetUserData(user.Id, child.GetUserDataKey()); diff --git a/MediaBrowser.Server.Implementations/Persistence/SqliteNotificationsRepository.cs b/MediaBrowser.Server.Implementations/Persistence/SqliteNotificationsRepository.cs index f755bd4e6..d85b1d874 100644 --- a/MediaBrowser.Server.Implementations/Persistence/SqliteNotificationsRepository.cs +++ b/MediaBrowser.Server.Implementations/Persistence/SqliteNotificationsRepository.cs @@ -1,4 +1,6 @@ -using MediaBrowser.Controller.Notifications; +using System.IO; +using MediaBrowser.Controller; +using MediaBrowser.Controller.Notifications; using MediaBrowser.Model.Logging; using MediaBrowser.Model.Notifications; using System; @@ -12,15 +14,15 @@ namespace MediaBrowser.Server.Implementations.Persistence { public class SqliteNotificationsRepository : INotificationsRepository { - private readonly IDbConnection _connection; + private IDbConnection _connection; private readonly ILogger _logger; + private readonly IServerApplicationPaths _appPaths; private readonly SemaphoreSlim _writeLock = new SemaphoreSlim(1, 1); - public SqliteNotificationsRepository(IDbConnection connection, ILogManager logManager) + public SqliteNotificationsRepository(ILogManager logManager, IServerApplicationPaths appPaths) { - _connection = connection; - + _appPaths = appPaths; _logger = logManager.GetLogger(GetType().Name); } @@ -31,8 +33,12 @@ namespace MediaBrowser.Server.Implementations.Persistence private IDbCommand _replaceNotificationCommand; private IDbCommand _markReadCommand; - public void Initialize() + public async Task Initialize() { + var dbFile = Path.Combine(_appPaths.DataPath, "notifications.db"); + + _connection = await SqliteExtensions.ConnectToDb(dbFile).ConfigureAwait(false); + string[] queries = { "create table if not exists Notifications (Id GUID NOT NULL, UserId GUID NOT NULL, Date DATETIME NOT NULL, Name TEXT NOT NULL, Description TEXT, Url TEXT, Level TEXT NOT NULL, IsRead BOOLEAN NOT NULL, Category TEXT NOT NULL, RelatedId TEXT, PRIMARY KEY (Id, UserId))", diff --git a/MediaBrowser.Server.Implementations/Persistence/SqliteUserRepository.cs b/MediaBrowser.Server.Implementations/Persistence/SqliteUserRepository.cs index c96ed970a..1aa0e8395 100644 --- a/MediaBrowser.Server.Implementations/Persistence/SqliteUserRepository.cs +++ b/MediaBrowser.Server.Implementations/Persistence/SqliteUserRepository.cs @@ -1,10 +1,12 @@ -using MediaBrowser.Controller.Entities; +using MediaBrowser.Controller; +using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Persistence; using MediaBrowser.Model.Logging; using MediaBrowser.Model.Serialization; using System; using System.Collections.Generic; using System.Data; +using System.IO; using System.Threading; using System.Threading.Tasks; @@ -20,6 +22,7 @@ namespace MediaBrowser.Server.Implementations.Persistence private readonly SemaphoreSlim _writeLock = new SemaphoreSlim(1, 1); private IDbConnection _connection; + private readonly IServerApplicationPaths _appPaths; /// <summary> /// Gets the name of the repository @@ -42,19 +45,19 @@ namespace MediaBrowser.Server.Implementations.Persistence /// <summary> /// Initializes a new instance of the <see cref="SqliteUserRepository" /> class. /// </summary> - /// <param name="connection">The connection.</param> /// <param name="jsonSerializer">The json serializer.</param> /// <param name="logManager">The log manager.</param> + /// <param name="appPaths">The app paths.</param> /// <exception cref="System.ArgumentNullException">appPaths</exception> - public SqliteUserRepository(IDbConnection connection, IJsonSerializer jsonSerializer, ILogManager logManager) + public SqliteUserRepository(IJsonSerializer jsonSerializer, ILogManager logManager, IServerApplicationPaths appPaths) { if (jsonSerializer == null) { throw new ArgumentNullException("jsonSerializer"); } - _connection = connection; _jsonSerializer = jsonSerializer; + _appPaths = appPaths; _logger = logManager.GetLogger(GetType().Name); } @@ -63,8 +66,12 @@ namespace MediaBrowser.Server.Implementations.Persistence /// Opens the connection to the database /// </summary> /// <returns>Task.</returns> - public void Initialize() + public async Task Initialize() { + var dbFile = Path.Combine(_appPaths.DataPath, "users.db"); + + _connection = await SqliteExtensions.ConnectToDb(dbFile).ConfigureAwait(false); + string[] queries = { "create table if not exists users (guid GUID primary key, data BLOB)", |
