mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-11-16 18:42:52 -07:00
commit
d7738e407c
@ -118,7 +118,7 @@ namespace MediaBrowser.Api
|
||||
config.EnableStandaloneMusicKeys = true;
|
||||
config.EnableCaseSensitiveItemIds = true;
|
||||
config.EnableFolderView = true;
|
||||
config.SchemaVersion = 95;
|
||||
config.SchemaVersion = 96;
|
||||
}
|
||||
|
||||
public void Post(UpdateStartupConfiguration request)
|
||||
|
@ -8,6 +8,10 @@ namespace MediaBrowser.Model.Channels
|
||||
|
||||
PhotoAlbum = 2,
|
||||
|
||||
MusicArtist = 3
|
||||
MusicArtist = 3,
|
||||
|
||||
Series = 4,
|
||||
|
||||
Season = 5
|
||||
}
|
||||
}
|
@ -1258,6 +1258,14 @@ namespace MediaBrowser.Server.Implementations.Channels
|
||||
{
|
||||
item = GetItemById<PhotoAlbum>(info.Id, channelProvider.Name, channelProvider.DataVersion, out isNew);
|
||||
}
|
||||
else if (info.FolderType == ChannelFolderType.Series)
|
||||
{
|
||||
item = GetItemById<Series>(info.Id, channelProvider.Name, channelProvider.DataVersion, out isNew);
|
||||
}
|
||||
else if (info.FolderType == ChannelFolderType.Season)
|
||||
{
|
||||
item = GetItemById<Season>(info.Id, channelProvider.Name, channelProvider.DataVersion, out isNew);
|
||||
}
|
||||
else
|
||||
{
|
||||
item = GetItemById<Folder>(info.Id, channelProvider.Name, channelProvider.DataVersion, out isNew);
|
||||
|
@ -95,7 +95,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
||||
private IDbCommand _updateInheritedRatingCommand;
|
||||
private IDbCommand _updateInheritedTagsCommand;
|
||||
|
||||
public const int LatestSchemaVersion = 95;
|
||||
public const int LatestSchemaVersion = 96;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="SqliteItemRepository"/> class.
|
||||
@ -128,7 +128,8 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
||||
connection.RunQueries(new[]
|
||||
{
|
||||
"pragma temp_store = memory",
|
||||
"PRAGMA main.locking_mode=EXCLUSIVE"
|
||||
"pragma default_temp_store = memory",
|
||||
"PRAGMA locking_mode=EXCLUSIVE"
|
||||
|
||||
}, Logger);
|
||||
|
||||
@ -139,7 +140,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
||||
/// Opens the connection to the database
|
||||
/// </summary>
|
||||
/// <returns>Task.</returns>
|
||||
public async Task Initialize()
|
||||
public async Task Initialize(SqliteUserDataRepository userDataRepo)
|
||||
{
|
||||
_connection = await CreateConnection(false).ConfigureAwait(false);
|
||||
|
||||
@ -163,18 +164,22 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
||||
"create index if not exists idx_ItemValues2 on ItemValues(ItemId,Type)",
|
||||
|
||||
"create table if not exists ProviderIds (ItemId GUID, Name TEXT, Value TEXT, PRIMARY KEY (ItemId, Name))",
|
||||
"create index if not exists Idx_ProviderIds on ProviderIds(ItemId)",
|
||||
// covering index
|
||||
"create index if not exists Idx_ProviderIds1 on ProviderIds(ItemId,Name,Value)",
|
||||
|
||||
"create table if not exists Images (ItemId GUID NOT NULL, Path TEXT NOT NULL, ImageType INT NOT NULL, DateModified DATETIME, IsPlaceHolder BIT NOT NULL, SortOrder INT)",
|
||||
"create index if not exists idx_Images on Images(ItemId)",
|
||||
|
||||
"create table if not exists People (ItemId GUID, Name TEXT NOT NULL, Role TEXT, PersonType TEXT, SortOrder int, ListOrder int)",
|
||||
|
||||
"drop index if exists idxPeopleItemId",
|
||||
"create index if not exists idxPeopleItemId1 on People(ItemId,ListOrder)",
|
||||
"create index if not exists idxPeopleName on People(Name)",
|
||||
|
||||
"create table if not exists "+ChaptersTableName+" (ItemId GUID, ChapterIndex INT, StartPositionTicks BIGINT, Name TEXT, ImagePath TEXT, PRIMARY KEY (ItemId, ChapterIndex))",
|
||||
|
||||
createMediaStreamsTableCommand,
|
||||
|
||||
"create index if not exists idx_mediastreams1 on mediastreams(ItemId)",
|
||||
|
||||
};
|
||||
@ -261,29 +266,45 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
||||
_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, "UserDataKeys", "Priority", "INT");
|
||||
_connection.AddColumn(Logger, "ItemValues", "CleanValue", "Text");
|
||||
|
||||
string[] postQueries =
|
||||
|
||||
{
|
||||
// obsolete
|
||||
"drop index if exists idx_TypedBaseItems",
|
||||
"drop index if exists idx_mediastreams",
|
||||
"drop index if exists idx_"+ChaptersTableName,
|
||||
"drop index if exists idx_UserDataKeys1",
|
||||
"drop index if exists idx_UserDataKeys2",
|
||||
"drop index if exists idx_TypeTopParentId3",
|
||||
"drop index if exists idx_TypeTopParentId2",
|
||||
"drop index if exists idx_TypeTopParentId4",
|
||||
"drop index if exists idx_Type",
|
||||
"drop index if exists idx_TypeTopParentId",
|
||||
"drop index if exists idx_GuidType",
|
||||
"drop index if exists idx_TopParentId",
|
||||
"drop index if exists idx_TypeTopParentId6",
|
||||
"drop index if exists idx_ItemValues2",
|
||||
"drop index if exists Idx_ProviderIds",
|
||||
|
||||
"create index if not exists idx_PresentationUniqueKey on TypedBaseItems(PresentationUniqueKey)",
|
||||
"create index if not exists idx_GuidType on TypedBaseItems(Guid,Type)",
|
||||
"create index if not exists idx_GuidTypeIsFolderIsVirtualItem on TypedBaseItems(Guid,Type,IsFolder,IsVirtualItem)",
|
||||
//"create index if not exists idx_GuidMediaTypeIsFolderIsVirtualItem on TypedBaseItems(Guid,MediaType,IsFolder,IsVirtualItem)",
|
||||
"create index if not exists idx_CleanNameType on TypedBaseItems(CleanName,Type)",
|
||||
"create index if not exists idx_Type on TypedBaseItems(Type)",
|
||||
"create index if not exists idx_TopParentId on TypedBaseItems(TopParentId)",
|
||||
"create index if not exists idx_TypeTopParentId on TypedBaseItems(Type,TopParentId)",
|
||||
|
||||
// covering index
|
||||
"create index if not exists idx_TopParentIdGuid on TypedBaseItems(TopParentId,Guid)",
|
||||
|
||||
// live tv programs
|
||||
"create index if not exists idx_TypeTopParentIdStartDate on TypedBaseItems(Type,TopParentId,StartDate)",
|
||||
|
||||
// used by movie suggestions
|
||||
"create index if not exists idx_TypeTopParentIdGroup on TypedBaseItems(Type,TopParentId,PresentationUniqueKey)",
|
||||
"create index if not exists idx_TypeTopParentId2 on TypedBaseItems(TopParentId,MediaType,IsVirtualItem)",
|
||||
"create index if not exists idx_TypeTopParentId3 on TypedBaseItems(TopParentId,IsFolder,IsVirtualItem)",
|
||||
"create index if not exists idx_TypeTopParentId4 on TypedBaseItems(TopParentId,Type,IsVirtualItem)",
|
||||
"create index if not exists idx_TypeTopParentId5 on TypedBaseItems(TopParentId,IsVirtualItem)",
|
||||
"create index if not exists idx_TypeTopParentId6 on TypedBaseItems(TopParentId,Type,IsVirtualItem,PresentationUniqueKey)",
|
||||
|
||||
// latest items
|
||||
"create index if not exists idx_TypeTopParentId9 on TypedBaseItems(TopParentId,Type,IsVirtualItem,PresentationUniqueKey,DateCreated)",
|
||||
@ -294,9 +315,10 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
||||
|
||||
// items by name
|
||||
"create index if not exists idx_ItemValues3 on ItemValues(ItemId,Type,CleanValue)",
|
||||
"create index if not exists idx_ItemValues4 on ItemValues(ItemId,Type,Value,CleanValue)",
|
||||
|
||||
//"create index if not exists idx_UserDataKeys1 on UserDataKeys(ItemId)",
|
||||
"create index if not exists idx_UserDataKeys2 on UserDataKeys(ItemId,Priority)"
|
||||
// covering index
|
||||
"create index if not exists idx_UserDataKeys3 on UserDataKeys(ItemId,Priority,UserDataKey)"
|
||||
};
|
||||
|
||||
_connection.RunQueries(postQueries, Logger);
|
||||
@ -306,6 +328,8 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
||||
new MediaStreamColumns(_connection, Logger).AddColumns();
|
||||
|
||||
DataExtensions.Attach(_connection, Path.Combine(_config.ApplicationPaths.DataPath, "userdata_v2.db"), "UserDataDb");
|
||||
await userDataRepo.Initialize(_connection).ConfigureAwait(false);
|
||||
//await Vacuum(_connection).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
private readonly string[] _retriveItemColumns =
|
||||
@ -487,7 +511,8 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
||||
"DateLastMediaAdded",
|
||||
"Album",
|
||||
"IsVirtualItem",
|
||||
"SeriesName"
|
||||
"SeriesName",
|
||||
"UserDataKey"
|
||||
};
|
||||
_saveItemCommand = _connection.CreateCommand();
|
||||
_saveItemCommand.CommandText = "replace into TypedBaseItems (" + string.Join(",", saveColumns.ToArray()) + ") values (";
|
||||
@ -916,6 +941,8 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
||||
_saveItemCommand.GetParameter(index++).Value = null;
|
||||
}
|
||||
|
||||
_saveItemCommand.GetParameter(index++).Value = item.GetUserDataKeys().FirstOrDefault();
|
||||
|
||||
_saveItemCommand.Transaction = transaction;
|
||||
|
||||
_saveItemCommand.ExecuteNonQuery();
|
||||
@ -1714,6 +1741,11 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
if (_config.Configuration.SchemaVersion >= 96)
|
||||
{
|
||||
return " left join UserDataDb.UserData on UserDataKey=UserDataDb.UserData.Key And (UserId=@UserId)";
|
||||
}
|
||||
|
||||
return " left join UserDataDb.UserData on (select UserDataKey from UserDataKeys where ItemId=Guid order by Priority LIMIT 1)=UserDataDb.UserData.Key And (UserId=@UserId)";
|
||||
}
|
||||
|
||||
@ -1819,7 +1851,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
||||
var slowThreshold = 1000;
|
||||
|
||||
#if DEBUG
|
||||
slowThreshold = 80;
|
||||
slowThreshold = 50;
|
||||
#endif
|
||||
|
||||
if (elapsed >= slowThreshold)
|
||||
|
@ -56,17 +56,21 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
||||
/// Opens the connection to the database
|
||||
/// </summary>
|
||||
/// <returns>Task.</returns>
|
||||
public async Task Initialize()
|
||||
public async Task Initialize(IDbConnection connection)
|
||||
{
|
||||
_connection = await CreateConnection(false).ConfigureAwait(false);
|
||||
_connection = connection;
|
||||
|
||||
string[] queries = {
|
||||
|
||||
"create table if not exists userdata (key nvarchar, userId GUID, rating float null, played bit, playCount int, isFavorite bit, playbackPositionTicks bigint, lastPlayedDate datetime null)",
|
||||
"create table if not exists UserDataDb.userdata (key nvarchar, userId GUID, rating float null, played bit, playCount int, isFavorite bit, playbackPositionTicks bigint, lastPlayedDate datetime null)",
|
||||
|
||||
"create index if not exists idx_userdata on userdata(key)",
|
||||
"create unique index if not exists userdataindex on userdata (key, userId)",
|
||||
"create index if not exists userdataindex1 on userdata (key, userId)",
|
||||
"drop index if exists UserDataDb.idx_userdata",
|
||||
"drop index if exists UserDataDb.idx_userdata1",
|
||||
"drop index if exists UserDataDb.idx_userdata2",
|
||||
"drop index if exists UserDataDb.userdataindex1",
|
||||
|
||||
"create unique index if not exists UserDataDb.userdataindex on userdata (key, userId)",
|
||||
"create index if not exists UserDataDb.userdataindex2 on userdata (key, userId, played)",
|
||||
|
||||
//pragmas
|
||||
"pragma temp_store = memory",
|
||||
@ -332,18 +336,19 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
||||
using (var cmd = _connection.CreateCommand())
|
||||
{
|
||||
var index = 0;
|
||||
var excludeIds = new List<string>();
|
||||
var userdataKeys = new List<string>();
|
||||
var builder = new StringBuilder();
|
||||
foreach (var key in keys)
|
||||
{
|
||||
var paramName = "@Key" + index;
|
||||
excludeIds.Add("Key =" + paramName);
|
||||
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 ", excludeIds.ToArray());
|
||||
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 + ") ";
|
||||
|
||||
|
@ -587,8 +587,11 @@ namespace MediaBrowser.Server.Startup.Common
|
||||
RegisterSingleInstance(SubtitleEncoder);
|
||||
|
||||
await displayPreferencesRepo.Initialize().ConfigureAwait(false);
|
||||
await ConfigureUserDataRepositories().ConfigureAwait(false);
|
||||
await itemRepo.Initialize().ConfigureAwait(false);
|
||||
|
||||
var userDataRepo = new SqliteUserDataRepository(LogManager, ApplicationPaths, NativeApp.GetDbConnector());
|
||||
|
||||
((UserDataManager)UserDataManager).Repository = userDataRepo;
|
||||
await itemRepo.Initialize(userDataRepo).ConfigureAwait(false);
|
||||
((LibraryManager)LibraryManager).ItemRepository = ItemRepository;
|
||||
await ConfigureNotificationsRepository().ConfigureAwait(false);
|
||||
progress.Report(100);
|
||||
@ -751,18 +754,6 @@ namespace MediaBrowser.Server.Startup.Common
|
||||
RegisterSingleInstance(NotificationsRepository);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Configures the user data repositories.
|
||||
/// </summary>
|
||||
private async Task ConfigureUserDataRepositories()
|
||||
{
|
||||
var repo = new SqliteUserDataRepository(LogManager, ApplicationPaths, NativeApp.GetDbConnector());
|
||||
|
||||
await repo.Initialize().ConfigureAwait(false);
|
||||
|
||||
((UserDataManager)UserDataManager).Repository = repo;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Dirty hacks
|
||||
/// </summary>
|
||||
|
@ -83,8 +83,8 @@
|
||||
<Reference Include="System.Configuration" />
|
||||
<Reference Include="System.Configuration.Install" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Data.SQLite, Version=1.0.101.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Data.SQLite.Core.1.0.101.0\lib\net46\System.Data.SQLite.dll</HintPath>
|
||||
<Reference Include="System.Data.SQLite, Version=1.0.102.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Data.SQLite.Core.1.0.102.0\lib\net46\System.Data.SQLite.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Drawing" />
|
||||
@ -1112,12 +1112,12 @@
|
||||
<PostBuildEvent>
|
||||
</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
<Import Project="..\packages\System.Data.SQLite.Core.1.0.101.0\build\net46\System.Data.SQLite.Core.targets" Condition="Exists('..\packages\System.Data.SQLite.Core.1.0.101.0\build\net46\System.Data.SQLite.Core.targets')" />
|
||||
<Import Project="..\packages\System.Data.SQLite.Core.1.0.102.0\build\net46\System.Data.SQLite.Core.targets" Condition="Exists('..\packages\System.Data.SQLite.Core.1.0.102.0\build\net46\System.Data.SQLite.Core.targets')" />
|
||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||
<PropertyGroup>
|
||||
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
|
||||
</PropertyGroup>
|
||||
<Error Condition="!Exists('..\packages\System.Data.SQLite.Core.1.0.101.0\build\net46\System.Data.SQLite.Core.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\System.Data.SQLite.Core.1.0.101.0\build\net46\System.Data.SQLite.Core.targets'))" />
|
||||
<Error Condition="!Exists('..\packages\System.Data.SQLite.Core.1.0.102.0\build\net46\System.Data.SQLite.Core.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\System.Data.SQLite.Core.1.0.102.0\build\net46\System.Data.SQLite.Core.targets'))" />
|
||||
</Target>
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
|
@ -3,5 +3,5 @@
|
||||
<package id="CommonIO" version="1.0.0.9" targetFramework="net45" />
|
||||
<package id="ImageMagickSharp" version="1.0.0.18" targetFramework="net45" />
|
||||
<package id="Patterns.Logging" version="1.0.0.2" targetFramework="net45" />
|
||||
<package id="System.Data.SQLite.Core" version="1.0.101.0" targetFramework="net46" />
|
||||
<package id="System.Data.SQLite.Core" version="1.0.102.0" targetFramework="net46" />
|
||||
</packages>
|
Loading…
Reference in New Issue
Block a user