Merge pull request #2296 from MediaBrowser/dev

Dev
This commit is contained in:
Luke 2016-11-19 16:07:42 -05:00 committed by GitHub
commit d570130e92
10 changed files with 215 additions and 291 deletions

View File

@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using MediaBrowser.Model.IO;
using MediaBrowser.Model.Serialization;
@ -127,5 +128,14 @@ namespace Emby.Server.Implementations.Data
return stream.ToArray();
}
}
public static void Attach(IDatabaseConnection db, string path, string alias)
{
var commandText = string.Format("attach ? as {0};", alias);
var paramList = new List<object>();
paramList.Add(path);
db.Execute(commandText, paramList.ToArray());
}
}
}

View File

@ -139,7 +139,7 @@
// /// <returns>Task.</returns>
// public async Task Initialize(SqliteUserDataRepository userDataRepo)
// {
// _connection = await CreateConnection(false).ConfigureAwait(false);
// _connection = CreateConnection(false);
// var createMediaStreamsTableCommand
// = "create table if not exists mediastreams (ItemId GUID, StreamIndex INT, StreamType TEXT, Codec TEXT, Language TEXT, ChannelLayout TEXT, Profile TEXT, AspectRatio TEXT, Path TEXT, IsInterlaced BIT, BitRate INT NULL, Channels INT NULL, SampleRate INT NULL, IsDefault BIT, IsForced BIT, IsExternal BIT, Height INT NULL, Width INT NULL, AverageFrameRate FLOAT NULL, RealFrameRate FLOAT NULL, Level FLOAT NULL, PixelFormat TEXT, BitDepth INT NULL, IsAnamorphic BIT NULL, RefFrames INT NULL, CodecTag TEXT NULL, Comment TEXT NULL, NalLengthSize TEXT NULL, IsAvc BIT NULL, Title TEXT NULL, TimeBase TEXT NULL, CodecTimeBase TEXT NULL, PRIMARY KEY (ItemId, StreamIndex))";
@ -168,109 +168,131 @@
// };
// _connection.RunQueries(queries, Logger);
// _connection.RunQueries(queries);
// _connection.AddColumn(Logger, "AncestorIds", "AncestorIdText", "Text");
// _connection.RunInTransaction(db =>
// {
// var existingColumnNames = GetColumnNames(db, "AncestorIds");
// AddColumn(db, "AncestorIds", "AncestorIdText", "Text", existingColumnNames);
// _connection.AddColumn(Logger, "TypedBaseItems", "Path", "Text");
// _connection.AddColumn(Logger, "TypedBaseItems", "StartDate", "DATETIME");
// _connection.AddColumn(Logger, "TypedBaseItems", "EndDate", "DATETIME");
// _connection.AddColumn(Logger, "TypedBaseItems", "ChannelId", "Text");
// _connection.AddColumn(Logger, "TypedBaseItems", "IsMovie", "BIT");
// _connection.AddColumn(Logger, "TypedBaseItems", "IsSports", "BIT");
// _connection.AddColumn(Logger, "TypedBaseItems", "IsKids", "BIT");
// _connection.AddColumn(Logger, "TypedBaseItems", "CommunityRating", "Float");
// _connection.AddColumn(Logger, "TypedBaseItems", "CustomRating", "Text");
// _connection.AddColumn(Logger, "TypedBaseItems", "IndexNumber", "INT");
// _connection.AddColumn(Logger, "TypedBaseItems", "IsLocked", "BIT");
// _connection.AddColumn(Logger, "TypedBaseItems", "Name", "Text");
// _connection.AddColumn(Logger, "TypedBaseItems", "OfficialRating", "Text");
// existingColumnNames = GetColumnNames(db, "TypedBaseItems");
// _connection.AddColumn(Logger, "TypedBaseItems", "MediaType", "Text");
// _connection.AddColumn(Logger, "TypedBaseItems", "Overview", "Text");
// _connection.AddColumn(Logger, "TypedBaseItems", "ParentIndexNumber", "INT");
// _connection.AddColumn(Logger, "TypedBaseItems", "PremiereDate", "DATETIME");
// _connection.AddColumn(Logger, "TypedBaseItems", "ProductionYear", "INT");
// _connection.AddColumn(Logger, "TypedBaseItems", "ParentId", "GUID");
// _connection.AddColumn(Logger, "TypedBaseItems", "Genres", "Text");
// _connection.AddColumn(Logger, "TypedBaseItems", "SchemaVersion", "INT");
// _connection.AddColumn(Logger, "TypedBaseItems", "SortName", "Text");
// _connection.AddColumn(Logger, "TypedBaseItems", "RunTimeTicks", "BIGINT");
// AddColumn(db, "TypedBaseItems", "Path", "Text", existingColumnNames);
// AddColumn(db, "TypedBaseItems", "StartDate", "DATETIME", existingColumnNames);
// AddColumn(db, "TypedBaseItems", "EndDate", "DATETIME", existingColumnNames);
// AddColumn(db, "TypedBaseItems", "ChannelId", "Text", existingColumnNames);
// AddColumn(db, "TypedBaseItems", "IsMovie", "BIT", existingColumnNames);
// AddColumn(db, "TypedBaseItems", "IsSports", "BIT", existingColumnNames);
// AddColumn(db, "TypedBaseItems", "IsKids", "BIT", existingColumnNames);
// AddColumn(db, "TypedBaseItems", "CommunityRating", "Float", existingColumnNames);
// AddColumn(db, "TypedBaseItems", "CustomRating", "Text", existingColumnNames);
// AddColumn(db, "TypedBaseItems", "IndexNumber", "INT", existingColumnNames);
// AddColumn(db, "TypedBaseItems", "IsLocked", "BIT", existingColumnNames);
// AddColumn(db, "TypedBaseItems", "Name", "Text", existingColumnNames);
// AddColumn(db, "TypedBaseItems", "OfficialRating", "Text", existingColumnNames);
// _connection.AddColumn(Logger, "TypedBaseItems", "OfficialRatingDescription", "Text");
// _connection.AddColumn(Logger, "TypedBaseItems", "HomePageUrl", "Text");
// _connection.AddColumn(Logger, "TypedBaseItems", "VoteCount", "INT");
// _connection.AddColumn(Logger, "TypedBaseItems", "DisplayMediaType", "Text");
// _connection.AddColumn(Logger, "TypedBaseItems", "DateCreated", "DATETIME");
// _connection.AddColumn(Logger, "TypedBaseItems", "DateModified", "DATETIME");
// AddColumn(db, "TypedBaseItems", "MediaType", "Text", existingColumnNames);
// AddColumn(db, "TypedBaseItems", "Overview", "Text", existingColumnNames);
// AddColumn(db, "TypedBaseItems", "ParentIndexNumber", "INT", existingColumnNames);
// AddColumn(db, "TypedBaseItems", "PremiereDate", "DATETIME", existingColumnNames);
// AddColumn(db, "TypedBaseItems", "ProductionYear", "INT", existingColumnNames);
// AddColumn(db, "TypedBaseItems", "ParentId", "GUID", existingColumnNames);
// AddColumn(db, "TypedBaseItems", "Genres", "Text", existingColumnNames);
// AddColumn(db, "TypedBaseItems", "SchemaVersion", "INT", existingColumnNames);
// AddColumn(db, "TypedBaseItems", "SortName", "Text", existingColumnNames);
// AddColumn(db, "TypedBaseItems", "RunTimeTicks", "BIGINT", existingColumnNames);
// _connection.AddColumn(Logger, "TypedBaseItems", "ForcedSortName", "Text");
// _connection.AddColumn(Logger, "TypedBaseItems", "IsOffline", "BIT");
// _connection.AddColumn(Logger, "TypedBaseItems", "LocationType", "Text");
// AddColumn(db, "TypedBaseItems", "OfficialRatingDescription", "Text", existingColumnNames);
// AddColumn(db, "TypedBaseItems", "HomePageUrl", "Text", existingColumnNames);
// AddColumn(db, "TypedBaseItems", "VoteCount", "INT", existingColumnNames);
// AddColumn(db, "TypedBaseItems", "DisplayMediaType", "Text", existingColumnNames);
// AddColumn(db, "TypedBaseItems", "DateCreated", "DATETIME", existingColumnNames);
// AddColumn(db, "TypedBaseItems", "DateModified", "DATETIME", existingColumnNames);
// _connection.AddColumn(Logger, "TypedBaseItems", "IsSeries", "BIT");
// _connection.AddColumn(Logger, "TypedBaseItems", "IsLive", "BIT");
// _connection.AddColumn(Logger, "TypedBaseItems", "IsNews", "BIT");
// _connection.AddColumn(Logger, "TypedBaseItems", "IsPremiere", "BIT");
// AddColumn(db, "TypedBaseItems", "ForcedSortName", "Text", existingColumnNames);
// AddColumn(db, "TypedBaseItems", "IsOffline", "BIT", existingColumnNames);
// AddColumn(db, "TypedBaseItems", "LocationType", "Text", existingColumnNames);
// _connection.AddColumn(Logger, "TypedBaseItems", "EpisodeTitle", "Text");
// _connection.AddColumn(Logger, "TypedBaseItems", "IsRepeat", "BIT");
// AddColumn(db, "TypedBaseItems", "IsSeries", "BIT", existingColumnNames);
// AddColumn(db, "TypedBaseItems", "IsLive", "BIT", existingColumnNames);
// AddColumn(db, "TypedBaseItems", "IsNews", "BIT", existingColumnNames);
// AddColumn(db, "TypedBaseItems", "IsPremiere", "BIT", existingColumnNames);
// _connection.AddColumn(Logger, "TypedBaseItems", "PreferredMetadataLanguage", "Text");
// _connection.AddColumn(Logger, "TypedBaseItems", "PreferredMetadataCountryCode", "Text");
// _connection.AddColumn(Logger, "TypedBaseItems", "IsHD", "BIT");
// _connection.AddColumn(Logger, "TypedBaseItems", "ExternalEtag", "Text");
// _connection.AddColumn(Logger, "TypedBaseItems", "DateLastRefreshed", "DATETIME");
// AddColumn(db, "TypedBaseItems", "EpisodeTitle", "Text", existingColumnNames);
// AddColumn(db, "TypedBaseItems", "IsRepeat", "BIT", existingColumnNames);
// _connection.AddColumn(Logger, "TypedBaseItems", "DateLastSaved", "DATETIME");
// _connection.AddColumn(Logger, "TypedBaseItems", "IsInMixedFolder", "BIT");
// _connection.AddColumn(Logger, "TypedBaseItems", "LockedFields", "Text");
// _connection.AddColumn(Logger, "TypedBaseItems", "Studios", "Text");
// _connection.AddColumn(Logger, "TypedBaseItems", "Audio", "Text");
// _connection.AddColumn(Logger, "TypedBaseItems", "ExternalServiceId", "Text");
// _connection.AddColumn(Logger, "TypedBaseItems", "Tags", "Text");
// _connection.AddColumn(Logger, "TypedBaseItems", "IsFolder", "BIT");
// _connection.AddColumn(Logger, "TypedBaseItems", "InheritedParentalRatingValue", "INT");
// _connection.AddColumn(Logger, "TypedBaseItems", "UnratedType", "Text");
// _connection.AddColumn(Logger, "TypedBaseItems", "TopParentId", "Text");
// _connection.AddColumn(Logger, "TypedBaseItems", "IsItemByName", "BIT");
// _connection.AddColumn(Logger, "TypedBaseItems", "SourceType", "Text");
// _connection.AddColumn(Logger, "TypedBaseItems", "TrailerTypes", "Text");
// _connection.AddColumn(Logger, "TypedBaseItems", "CriticRating", "Float");
// _connection.AddColumn(Logger, "TypedBaseItems", "CriticRatingSummary", "Text");
// _connection.AddColumn(Logger, "TypedBaseItems", "InheritedTags", "Text");
// _connection.AddColumn(Logger, "TypedBaseItems", "CleanName", "Text");
// _connection.AddColumn(Logger, "TypedBaseItems", "PresentationUniqueKey", "Text");
// _connection.AddColumn(Logger, "TypedBaseItems", "SlugName", "Text");
// _connection.AddColumn(Logger, "TypedBaseItems", "OriginalTitle", "Text");
// _connection.AddColumn(Logger, "TypedBaseItems", "PrimaryVersionId", "Text");
// _connection.AddColumn(Logger, "TypedBaseItems", "DateLastMediaAdded", "DATETIME");
// _connection.AddColumn(Logger, "TypedBaseItems", "Album", "Text");
// _connection.AddColumn(Logger, "TypedBaseItems", "IsVirtualItem", "BIT");
// _connection.AddColumn(Logger, "TypedBaseItems", "SeriesName", "Text");
// _connection.AddColumn(Logger, "TypedBaseItems", "UserDataKey", "Text");
// _connection.AddColumn(Logger, "TypedBaseItems", "SeasonName", "Text");
// _connection.AddColumn(Logger, "TypedBaseItems", "SeasonId", "GUID");
// _connection.AddColumn(Logger, "TypedBaseItems", "SeriesId", "GUID");
// _connection.AddColumn(Logger, "TypedBaseItems", "SeriesSortName", "Text");
// _connection.AddColumn(Logger, "TypedBaseItems", "ExternalSeriesId", "Text");
// _connection.AddColumn(Logger, "TypedBaseItems", "ShortOverview", "Text");
// _connection.AddColumn(Logger, "TypedBaseItems", "Tagline", "Text");
// _connection.AddColumn(Logger, "TypedBaseItems", "Keywords", "Text");
// _connection.AddColumn(Logger, "TypedBaseItems", "ProviderIds", "Text");
// _connection.AddColumn(Logger, "TypedBaseItems", "Images", "Text");
// _connection.AddColumn(Logger, "TypedBaseItems", "ProductionLocations", "Text");
// _connection.AddColumn(Logger, "TypedBaseItems", "ThemeSongIds", "Text");
// _connection.AddColumn(Logger, "TypedBaseItems", "ThemeVideoIds", "Text");
// _connection.AddColumn(Logger, "TypedBaseItems", "TotalBitrate", "INT");
// _connection.AddColumn(Logger, "TypedBaseItems", "ExtraType", "Text");
// _connection.AddColumn(Logger, "TypedBaseItems", "Artists", "Text");
// _connection.AddColumn(Logger, "TypedBaseItems", "AlbumArtists", "Text");
// _connection.AddColumn(Logger, "TypedBaseItems", "ExternalId", "Text");
// AddColumn(db, "TypedBaseItems", "PreferredMetadataLanguage", "Text", existingColumnNames);
// AddColumn(db, "TypedBaseItems", "PreferredMetadataCountryCode", "Text", existingColumnNames);
// AddColumn(db, "TypedBaseItems", "IsHD", "BIT", existingColumnNames);
// AddColumn(db, "TypedBaseItems", "ExternalEtag", "Text", existingColumnNames);
// AddColumn(db, "TypedBaseItems", "DateLastRefreshed", "DATETIME", existingColumnNames);
// _connection.AddColumn(Logger, "ItemValues", "CleanValue", "Text");
// AddColumn(db, "TypedBaseItems", "DateLastSaved", "DATETIME", existingColumnNames);
// AddColumn(db, "TypedBaseItems", "IsInMixedFolder", "BIT", existingColumnNames);
// AddColumn(db, "TypedBaseItems", "LockedFields", "Text", existingColumnNames);
// AddColumn(db, "TypedBaseItems", "Studios", "Text", existingColumnNames);
// AddColumn(db, "TypedBaseItems", "Audio", "Text", existingColumnNames);
// AddColumn(db, "TypedBaseItems", "ExternalServiceId", "Text", existingColumnNames);
// AddColumn(db, "TypedBaseItems", "Tags", "Text", existingColumnNames);
// AddColumn(db, "TypedBaseItems", "IsFolder", "BIT", existingColumnNames);
// AddColumn(db, "TypedBaseItems", "InheritedParentalRatingValue", "INT", existingColumnNames);
// AddColumn(db, "TypedBaseItems", "UnratedType", "Text", existingColumnNames);
// AddColumn(db, "TypedBaseItems", "TopParentId", "Text", existingColumnNames);
// AddColumn(db, "TypedBaseItems", "IsItemByName", "BIT", existingColumnNames);
// AddColumn(db, "TypedBaseItems", "SourceType", "Text", existingColumnNames);
// AddColumn(db, "TypedBaseItems", "TrailerTypes", "Text", existingColumnNames);
// AddColumn(db, "TypedBaseItems", "CriticRating", "Float", existingColumnNames);
// AddColumn(db, "TypedBaseItems", "CriticRatingSummary", "Text", existingColumnNames);
// AddColumn(db, "TypedBaseItems", "InheritedTags", "Text", existingColumnNames);
// AddColumn(db, "TypedBaseItems", "CleanName", "Text", existingColumnNames);
// AddColumn(db, "TypedBaseItems", "PresentationUniqueKey", "Text", existingColumnNames);
// AddColumn(db, "TypedBaseItems", "SlugName", "Text", existingColumnNames);
// AddColumn(db, "TypedBaseItems", "OriginalTitle", "Text", existingColumnNames);
// AddColumn(db, "TypedBaseItems", "PrimaryVersionId", "Text", existingColumnNames);
// AddColumn(db, "TypedBaseItems", "DateLastMediaAdded", "DATETIME", existingColumnNames);
// AddColumn(db, "TypedBaseItems", "Album", "Text", existingColumnNames);
// AddColumn(db, "TypedBaseItems", "IsVirtualItem", "BIT", existingColumnNames);
// AddColumn(db, "TypedBaseItems", "SeriesName", "Text", existingColumnNames);
// AddColumn(db, "TypedBaseItems", "UserDataKey", "Text", existingColumnNames);
// AddColumn(db, "TypedBaseItems", "SeasonName", "Text", existingColumnNames);
// AddColumn(db, "TypedBaseItems", "SeasonId", "GUID", existingColumnNames);
// AddColumn(db, "TypedBaseItems", "SeriesId", "GUID", existingColumnNames);
// AddColumn(db, "TypedBaseItems", "SeriesSortName", "Text", existingColumnNames);
// AddColumn(db, "TypedBaseItems", "ExternalSeriesId", "Text", existingColumnNames);
// AddColumn(db, "TypedBaseItems", "ShortOverview", "Text", existingColumnNames);
// AddColumn(db, "TypedBaseItems", "Tagline", "Text", existingColumnNames);
// AddColumn(db, "TypedBaseItems", "Keywords", "Text", existingColumnNames);
// AddColumn(db, "TypedBaseItems", "ProviderIds", "Text", existingColumnNames);
// AddColumn(db, "TypedBaseItems", "Images", "Text", existingColumnNames);
// AddColumn(db, "TypedBaseItems", "ProductionLocations", "Text", existingColumnNames);
// AddColumn(db, "TypedBaseItems", "ThemeSongIds", "Text", existingColumnNames);
// AddColumn(db, "TypedBaseItems", "ThemeVideoIds", "Text", existingColumnNames);
// AddColumn(db, "TypedBaseItems", "TotalBitrate", "INT", existingColumnNames);
// AddColumn(db, "TypedBaseItems", "ExtraType", "Text", existingColumnNames);
// AddColumn(db, "TypedBaseItems", "Artists", "Text", existingColumnNames);
// AddColumn(db, "TypedBaseItems", "AlbumArtists", "Text", existingColumnNames);
// AddColumn(db, "TypedBaseItems", "ExternalId", "Text", existingColumnNames);
// _connection.AddColumn(Logger, ChaptersTableName, "ImageDateModified", "DATETIME");
// existingColumnNames = GetColumnNames(db, "ItemValues");
// AddColumn(db, "ItemValues", "CleanValue", "Text", existingColumnNames);
// existingColumnNames = GetColumnNames(db, ChaptersTableName);
// AddColumn(db, ChaptersTableName, "ImageDateModified", "DATETIME", existingColumnNames);
// existingColumnNames = GetColumnNames(db, "MediaStreams");
// AddColumn(db, "MediaStreams", "IsAvc", "BIT", existingColumnNames);
// AddColumn(db, "MediaStreams", "TimeBase", "TEXT", existingColumnNames);
// AddColumn(db, "MediaStreams", "CodecTimeBase", "TEXT", existingColumnNames);
// AddColumn(db, "MediaStreams", "Title", "TEXT", existingColumnNames);
// AddColumn(db, "MediaStreams", "NalLengthSize", "TEXT", existingColumnNames);
// AddColumn(db, "MediaStreams", "Comment", "TEXT", existingColumnNames);
// AddColumn(db, "MediaStreams", "CodecTag", "TEXT", existingColumnNames);
// AddColumn(db, "MediaStreams", "PixelFormat", "TEXT", existingColumnNames);
// AddColumn(db, "MediaStreams", "BitDepth", "INT", existingColumnNames);
// AddColumn(db, "MediaStreams", "RefFrames", "INT", existingColumnNames);
// AddColumn(db, "MediaStreams", "KeyFrames", "TEXT", existingColumnNames);
// AddColumn(db, "MediaStreams", "IsAnamorphic", "BIT", existingColumnNames);
// });
// string[] postQueries =
@ -334,14 +356,12 @@
// "create index if not exists idx_ItemValues7 on ItemValues(Type,CleanValue,ItemId)"
// };
// _connection.RunQueries(postQueries, Logger);
// _connection.RunQueries(postQueries);
// PrepareStatements();
// new MediaStreamColumns(_connection, Logger).AddColumns();
// DataExtensions.Attach(_connection, Path.Combine(_config.ApplicationPaths.DataPath, "userdata_v2.db"), "UserDataDb");
// await userDataRepo.Initialize(_connection, WriteLock).ConfigureAwait(false);
// SqliteExtensions.Attach(_connection, Path.Combine(_config.ApplicationPaths.DataPath, "userdata_v2.db"), "UserDataDb");
// userDataRepo.Initialize(_connection, WriteLock);
// //await Vacuum(_connection).ConfigureAwait(false);
// }

View File

@ -1,8 +1,7 @@
//using System;
//using System.Collections.Generic;
//using System.Globalization;
//using System.IO;
//using System.Text;
//using System.Linq;
//using System.Threading;
//using System.Threading.Tasks;
//using MediaBrowser.Common.Configuration;
@ -125,7 +124,7 @@
// throw new ArgumentNullException("userId");
// }
// return PersistAllUserData(userId, userData, cancellationToken);
// return PersistAllUserData(userId, userData.ToList(), cancellationToken);
// }
// /// <summary>
@ -140,141 +139,58 @@
// {
// cancellationToken.ThrowIfCancellationRequested();
// await WriteLock.WaitAsync(cancellationToken).ConfigureAwait(false);
// IDbTransaction transaction = null;
// try
// using (WriteLock.Write())
// {
// transaction = _connection.BeginTransaction();
// using (var cmd = _connection.CreateCommand())
// _connection.RunInTransaction(db =>
// {
// cmd.CommandText = "replace into userdata (key, userId, rating,played,playCount,isFavorite,playbackPositionTicks,lastPlayedDate,AudioStreamIndex,SubtitleStreamIndex) values (@key, @userId, @rating,@played,@playCount,@isFavorite,@playbackPositionTicks,@lastPlayedDate,@AudioStreamIndex,@SubtitleStreamIndex)";
// cmd.Parameters.Add(cmd, "@key", DbType.String).Value = key;
// cmd.Parameters.Add(cmd, "@userId", DbType.Guid).Value = userId;
// cmd.Parameters.Add(cmd, "@rating", DbType.Double).Value = userData.Rating;
// cmd.Parameters.Add(cmd, "@played", DbType.Boolean).Value = userData.Played;
// cmd.Parameters.Add(cmd, "@playCount", DbType.Int32).Value = userData.PlayCount;
// cmd.Parameters.Add(cmd, "@isFavorite", DbType.Boolean).Value = userData.IsFavorite;
// cmd.Parameters.Add(cmd, "@playbackPositionTicks", DbType.Int64).Value = userData.PlaybackPositionTicks;
// cmd.Parameters.Add(cmd, "@lastPlayedDate", DbType.DateTime).Value = userData.LastPlayedDate;
// cmd.Parameters.Add(cmd, "@AudioStreamIndex", DbType.Int32).Value = userData.AudioStreamIndex;
// cmd.Parameters.Add(cmd, "@SubtitleStreamIndex", DbType.Int32).Value = userData.SubtitleStreamIndex;
// cmd.Transaction = transaction;
// cmd.ExecuteNonQuery();
// }
// transaction.Commit();
// SaveUserData(db, userId, key, userData);
// });
// }
// catch (OperationCanceledException)
// }
// private void SaveUserData(IDatabaseConnection db, Guid userId, string key, UserItemData userData)
// {
// var paramList = new List<object>();
// var commandText = "replace into userdata (key, userId, rating,played,playCount,isFavorite,playbackPositionTicks,lastPlayedDate,AudioStreamIndex,SubtitleStreamIndex) values (?, ?, ?,?,?,?,?,?,?,?)";
// paramList.Add(key);
// paramList.Add(userId.ToGuidParamValue());
// paramList.Add(userData.Rating);
// paramList.Add(userData.Played);
// paramList.Add(userData.PlayCount);
// paramList.Add(userData.IsFavorite);
// paramList.Add(userData.PlaybackPositionTicks);
// if (userData.LastPlayedDate.HasValue)
// {
// if (transaction != null)
// {
// transaction.Rollback();
// }
// throw;
// paramList.Add(userData.LastPlayedDate.Value.ToDateTimeParamValue());
// }
// catch (Exception e)
// else
// {
// Logger.ErrorException("Failed to save user data:", e);
// if (transaction != null)
// {
// transaction.Rollback();
// }
// throw;
// paramList.Add(null);
// }
// finally
// {
// if (transaction != null)
// {
// transaction.Dispose();
// }
// paramList.Add(userData.AudioStreamIndex);
// paramList.Add(userData.SubtitleStreamIndex);
// WriteLock.Release();
// }
// db.Execute(commandText, paramList.ToArray());
// }
// /// <summary>
// /// Persist all user data for the specified user
// /// </summary>
// /// <param name="userId"></param>
// /// <param name="userData"></param>
// /// <param name="cancellationToken"></param>
// /// <returns></returns>
// private async Task PersistAllUserData(Guid userId, IEnumerable<UserItemData> userData, CancellationToken cancellationToken)
// private async Task PersistAllUserData(Guid userId, List<UserItemData> userDataList, CancellationToken cancellationToken)
// {
// cancellationToken.ThrowIfCancellationRequested();
// await WriteLock.WaitAsync(cancellationToken).ConfigureAwait(false);
// IDbTransaction transaction = null;
// try
// using (WriteLock.Write())
// {
// transaction = _connection.BeginTransaction();
// foreach (var userItemData in userData)
// _connection.RunInTransaction(db =>
// {
// using (var cmd = _connection.CreateCommand())
// foreach (var userItemData in userDataList)
// {
// cmd.CommandText = "replace into userdata (key, userId, rating,played,playCount,isFavorite,playbackPositionTicks,lastPlayedDate,AudioStreamIndex,SubtitleStreamIndex) values (@key, @userId, @rating,@played,@playCount,@isFavorite,@playbackPositionTicks,@lastPlayedDate,@AudioStreamIndex,@SubtitleStreamIndex)";
// cmd.Parameters.Add(cmd, "@key", DbType.String).Value = userItemData.Key;
// cmd.Parameters.Add(cmd, "@userId", DbType.Guid).Value = userId;
// cmd.Parameters.Add(cmd, "@rating", DbType.Double).Value = userItemData.Rating;
// cmd.Parameters.Add(cmd, "@played", DbType.Boolean).Value = userItemData.Played;
// cmd.Parameters.Add(cmd, "@playCount", DbType.Int32).Value = userItemData.PlayCount;
// cmd.Parameters.Add(cmd, "@isFavorite", DbType.Boolean).Value = userItemData.IsFavorite;
// cmd.Parameters.Add(cmd, "@playbackPositionTicks", DbType.Int64).Value = userItemData.PlaybackPositionTicks;
// cmd.Parameters.Add(cmd, "@lastPlayedDate", DbType.DateTime).Value = userItemData.LastPlayedDate;
// cmd.Parameters.Add(cmd, "@AudioStreamIndex", DbType.Int32).Value = userItemData.AudioStreamIndex;
// cmd.Parameters.Add(cmd, "@SubtitleStreamIndex", DbType.Int32).Value = userItemData.SubtitleStreamIndex;
// cmd.Transaction = transaction;
// cmd.ExecuteNonQuery();
// SaveUserData(db, userId, userItemData.Key, userItemData);
// }
// cancellationToken.ThrowIfCancellationRequested();
// }
// transaction.Commit();
// }
// catch (OperationCanceledException)
// {
// if (transaction != null)
// {
// transaction.Rollback();
// }
// throw;
// }
// catch (Exception e)
// {
// Logger.ErrorException("Failed to save user data:", e);
// if (transaction != null)
// {
// transaction.Rollback();
// }
// throw;
// }
// finally
// {
// if (transaction != null)
// {
// transaction.Dispose();
// }
// WriteLock.Release();
// });
// }
// }
@ -300,23 +216,18 @@
// throw new ArgumentNullException("key");
// }
// using (var cmd = _connection.CreateCommand())
// var commandText = "select key,userid,rating,played,playCount,isFavorite,playbackPositionTicks,lastPlayedDate,AudioStreamIndex,SubtitleStreamIndex from userdata where key = ? and userId=?";
// var paramList = new List<object>();
// paramList.Add(key);
// paramList.Add(userId.ToGuidParamValue());
// foreach (var row in _connection.Query(commandText, paramList.ToArray()))
// {
// cmd.CommandText = "select key,userid,rating,played,playCount,isFavorite,playbackPositionTicks,lastPlayedDate,AudioStreamIndex,SubtitleStreamIndex from userdata where key = @key and userId=@userId";
// cmd.Parameters.Add(cmd, "@key", DbType.String).Value = key;
// cmd.Parameters.Add(cmd, "@userId", DbType.Guid).Value = userId;
// using (var reader = cmd.ExecuteReader(CommandBehavior.SequentialAccess | CommandBehavior.SingleResult | CommandBehavior.SingleRow))
// {
// if (reader.Read())
// {
// return ReadRow(reader);
// }
// }
// return null;
// return ReadRow(row);
// }
// return null;
// }
// public UserItemData GetUserData(Guid userId, List<string> keys)
@ -330,40 +241,12 @@
// throw new ArgumentNullException("keys");
// }
// using (var cmd = _connection.CreateCommand())
// if (keys.Count == 0)
// {
// var index = 0;
// var userdataKeys = new List<string>();
// var builder = new StringBuilder();
// foreach (var key in keys)
// {
// var paramName = "@Key" + index;
// userdataKeys.Add("Key =" + paramName);
// cmd.Parameters.Add(cmd, paramName, DbType.String).Value = key;
// builder.Append(" WHEN Key=" + paramName + " THEN " + index);
// index++;
// break;
// }
// var keyText = string.Join(" OR ", userdataKeys.ToArray());
// cmd.CommandText = "select key,userid,rating,played,playCount,isFavorite,playbackPositionTicks,lastPlayedDate,AudioStreamIndex,SubtitleStreamIndex from userdata where userId=@userId AND (" + keyText + ") ";
// cmd.CommandText += " ORDER BY (Case " + builder + " Else " + keys.Count.ToString(CultureInfo.InvariantCulture) + " End )";
// cmd.CommandText += " LIMIT 1";
// cmd.Parameters.Add(cmd, "@userId", DbType.Guid).Value = userId;
// using (var reader = cmd.ExecuteReader(CommandBehavior.SequentialAccess | CommandBehavior.SingleResult | CommandBehavior.SingleRow))
// {
// if (reader.Read())
// {
// return ReadRow(reader);
// }
// }
// return null;
// }
// return GetUserData(userId, keys[0]);
// }
// /// <summary>
@ -378,56 +261,58 @@
// throw new ArgumentNullException("userId");
// }
// using (var cmd = _connection.CreateCommand())
// var list = new List<UserItemData>();
// using (WriteLock.Read())
// {
// cmd.CommandText = "select key,userid,rating,played,playCount,isFavorite,playbackPositionTicks,lastPlayedDate,AudioStreamIndex,SubtitleStreamIndex from userdata where userId=@userId";
// var commandText = "select key,userid,rating,played,playCount,isFavorite,playbackPositionTicks,lastPlayedDate,AudioStreamIndex,SubtitleStreamIndex from userdata where userId=?";
// cmd.Parameters.Add(cmd, "@userId", DbType.Guid).Value = userId;
// var paramList = new List<object>();
// paramList.Add(userId.ToGuidParamValue());
// using (var reader = cmd.ExecuteReader(CommandBehavior.SequentialAccess | CommandBehavior.SingleResult))
// foreach (var row in _connection.Query(commandText, paramList.ToArray()))
// {
// while (reader.Read())
// {
// yield return ReadRow(reader);
// }
// list.Add(ReadRow(row));
// }
// }
// return list;
// }
// /// <summary>
// /// Read a row from the specified reader into the provided userData object
// /// </summary>
// /// <param name="reader"></param>
// private UserItemData ReadRow(IDataReader reader)
// private UserItemData ReadRow(IReadOnlyList<IResultSetValue> reader)
// {
// var userData = new UserItemData();
// userData.Key = reader.GetString(0);
// userData.UserId = reader.GetGuid(1);
// userData.Key = reader[0].ToString();
// userData.UserId = reader[1].ReadGuid();
// if (!reader.IsDBNull(2))
// if (reader[2].SQLiteType != SQLiteType.Null)
// {
// userData.Rating = reader.GetDouble(2);
// userData.Rating = reader[2].ToDouble();
// }
// userData.Played = reader.GetBoolean(3);
// userData.PlayCount = reader.GetInt32(4);
// userData.IsFavorite = reader.GetBoolean(5);
// userData.PlaybackPositionTicks = reader.GetInt64(6);
// userData.Played = reader[3].ToBool();
// userData.PlayCount = reader[4].ToInt();
// userData.IsFavorite = reader[5].ToBool();
// userData.PlaybackPositionTicks = reader[6].ToInt64();
// if (!reader.IsDBNull(7))
// if (reader[7].SQLiteType != SQLiteType.Null)
// {
// userData.LastPlayedDate = reader.GetDateTime(7).ToUniversalTime();
// userData.LastPlayedDate = reader[7].ReadDateTime();
// }
// if (!reader.IsDBNull(8))
// if (reader[8].SQLiteType != SQLiteType.Null)
// {
// userData.AudioStreamIndex = reader.GetInt32(8);
// userData.AudioStreamIndex = reader[8].ToInt();
// }
// if (!reader.IsDBNull(9))
// if (reader[9].SQLiteType != SQLiteType.Null)
// {
// userData.SubtitleStreamIndex = reader.GetInt32(9);
// userData.SubtitleStreamIndex = reader[9].ToInt();
// }
// return userData;

View File

@ -108,11 +108,11 @@
<Private>True</Private>
</Reference>
<Reference Include="SQLitePCLRaw.core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=1488e028ca7ab535, processorArchitecture=MSIL">
<HintPath>..\packages\SQLitePCLRaw.core.1.1.0\lib\net45\SQLitePCLRaw.core.dll</HintPath>
<HintPath>..\packages\SQLitePCLRaw.core.1.1.1-pre20161109081005\lib\net45\SQLitePCLRaw.core.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="SQLitePCLRaw.provider.sqlite3, Version=1.0.0.0, Culture=neutral, PublicKeyToken=62684c7b4f184e3f, processorArchitecture=MSIL">
<HintPath>..\packages\SQLitePCLRaw.provider.sqlite3.net45.1.1.0\lib\net45\SQLitePCLRaw.provider.sqlite3.dll</HintPath>
<HintPath>..\packages\SQLitePCLRaw.provider.sqlite3.net45.1.1.1-pre20161109081005\lib\net45\SQLitePCLRaw.provider.sqlite3.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Data.SQLite">

View File

@ -3,7 +3,8 @@ using System.Collections.Generic;
using System.Reflection;
using Emby.Server.Core;
using Emby.Server.Core.Data;
using Emby.Server.Core.FFMpeg;
using Emby.Server.Implementations;
using Emby.Server.Implementations.FFMpeg;
using MediaBrowser.Model.IO;
using MediaBrowser.Model.Logging;
using MediaBrowser.Model.System;

View File

@ -20,6 +20,7 @@ using MonoMac.AppKit;
using MonoMac.Foundation;
using MonoMac.ObjCRuntime;
using Emby.Server.Core;
using Emby.Server.Implementations;
using Emby.Common.Implementations.Logging;
using Emby.Common.Implementations.EnvironmentInfo;
using Emby.Server.Mac.Native;
@ -43,7 +44,7 @@ namespace MediaBrowser.Server.Mac
var applicationPath = Assembly.GetEntryAssembly().Location;
var options = new StartupOptions();
var options = new StartupOptions(Environment.GetCommandLineArgs());
// Allow this to be specified on the command line.
var customProgramDataPath = options.GetOption("-programdata");

View File

@ -4,7 +4,7 @@ using MediaBrowser.Model.Logging;
using System;
using MonoMac.Foundation;
using MonoMac.AppKit;
using Emby.Server.Core.Browser;
using Emby.Server.Implementations.Browser;
namespace MediaBrowser.Server.Mac
{

View File

@ -6,7 +6,7 @@ namespace Emby.Server.Mac.Native
{
public class MonoFileSystem : ManagedFileSystem
{
public MonoFileSystem(ILogger logger, bool supportsAsyncFileStreams, bool enableManagedInvalidFileNameChars) : base(logger, supportsAsyncFileStreams, enableManagedInvalidFileNameChars, false)
public MonoFileSystem(ILogger logger, bool supportsAsyncFileStreams, bool enableManagedInvalidFileNameChars) : base(logger, supportsAsyncFileStreams, enableManagedInvalidFileNameChars, true)
{
}

View File

@ -230,6 +230,10 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="packages.config" />
<None Include="SQLitePCLRaw.provider.sqlite3.dll.config">
<SubType>Designer</SubType>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="System.Data.SQLite.dll.config">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<SubType>Designer</SubType>

View File

@ -0,0 +1,3 @@
<configuration>
<dllmap dll="sqlite3" target="libsqlite3.so" os="linux"/>
</configuration>