mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-07-09 03:04:24 -04:00
Merge branch 'master' of https://github.com/MediaBrowser/MediaBrowser
This commit is contained in:
commit
47be566fc6
@ -706,16 +706,10 @@ namespace MediaBrowser.Controller.Entities
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var saveTasks = new List<Task>();
|
await LibraryManager.CreateItems(newItems, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
foreach (var item in newItems)
|
foreach (var item in newItems)
|
||||||
{
|
{
|
||||||
if (saveTasks.Count > 50)
|
|
||||||
{
|
|
||||||
await Task.WhenAll(saveTasks).ConfigureAwait(false);
|
|
||||||
saveTasks.Clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!_children.TryAdd(item.Id, item))
|
if (!_children.TryAdd(item.Id, item))
|
||||||
{
|
{
|
||||||
Logger.Error("Failed to add {0}", item.Name);
|
Logger.Error("Failed to add {0}", item.Name);
|
||||||
@ -724,12 +718,8 @@ namespace MediaBrowser.Controller.Entities
|
|||||||
{
|
{
|
||||||
Logger.Debug("** " + item.Name + " Added to library.");
|
Logger.Debug("** " + item.Name + " Added to library.");
|
||||||
}
|
}
|
||||||
|
|
||||||
saveTasks.Add(LibraryManager.CreateItem(item, CancellationToken.None));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
await Task.WhenAll(saveTasks).ConfigureAwait(false);
|
|
||||||
|
|
||||||
await LibraryManager.SaveChildren(Id, newChildren, CancellationToken.None).ConfigureAwait(false);
|
await LibraryManager.SaveChildren(Id, newChildren, CancellationToken.None).ConfigureAwait(false);
|
||||||
|
|
||||||
//force the indexes to rebuild next time
|
//force the indexes to rebuild next time
|
||||||
|
@ -184,6 +184,14 @@ namespace MediaBrowser.Controller.Library
|
|||||||
/// <returns>Task.</returns>
|
/// <returns>Task.</returns>
|
||||||
Task CreateItem(BaseItem item, CancellationToken cancellationToken);
|
Task CreateItem(BaseItem item, CancellationToken cancellationToken);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates the items.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="items">The items.</param>
|
||||||
|
/// <param name="cancellationToken">The cancellation token.</param>
|
||||||
|
/// <returns>Task.</returns>
|
||||||
|
Task CreateItems(IEnumerable<BaseItem> items, CancellationToken cancellationToken);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Updates the item.
|
/// Updates the item.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -64,5 +64,13 @@ namespace MediaBrowser.Controller.Persistence
|
|||||||
/// <param name="criticReviews">The critic reviews.</param>
|
/// <param name="criticReviews">The critic reviews.</param>
|
||||||
/// <returns>Task.</returns>
|
/// <returns>Task.</returns>
|
||||||
Task SaveCriticReviews(Guid itemId, IEnumerable<ItemReview> criticReviews);
|
Task SaveCriticReviews(Guid itemId, IEnumerable<ItemReview> criticReviews);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Saves the items.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="items">The items.</param>
|
||||||
|
/// <param name="cancellationToken">The cancellation token.</param>
|
||||||
|
/// <returns>Task.</returns>
|
||||||
|
Task SaveItems(IEnumerable<BaseItem> items, CancellationToken cancellationToken);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -911,12 +911,12 @@ namespace MediaBrowser.Controller.Providers.Movies
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// The remove
|
/// The remove
|
||||||
/// </summary>
|
/// </summary>
|
||||||
const string remove = "\"'!`?";
|
const string Remove = "\"'!`?";
|
||||||
// "Face/Off" support.
|
// "Face/Off" support.
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The spacers
|
/// The spacers
|
||||||
/// </summary>
|
/// </summary>
|
||||||
const string spacers = "/,.:;\\(){}[]+-_=–*"; // (there are not actually two - in the they are different char codes)
|
const string Spacers = "/,.:;\\(){}[]+-_=–*"; // (there are not actually two - in the they are different char codes)
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The replace start numbers
|
/// The replace start numbers
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -996,11 +996,11 @@ namespace MediaBrowser.Controller.Providers.Movies
|
|||||||
{
|
{
|
||||||
// skip char modifier and diacritics
|
// skip char modifier and diacritics
|
||||||
}
|
}
|
||||||
else if (remove.IndexOf(c) > -1)
|
else if (Remove.IndexOf(c) > -1)
|
||||||
{
|
{
|
||||||
// skip chars we are removing
|
// skip chars we are removing
|
||||||
}
|
}
|
||||||
else if (spacers.IndexOf(c) > -1)
|
else if (Spacers.IndexOf(c) > -1)
|
||||||
{
|
{
|
||||||
sb.Append(" ");
|
sb.Append(" ");
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ namespace MediaBrowser.Controller.Providers.Movies
|
|||||||
{
|
{
|
||||||
public class OpenMovieDatabaseProvider : BaseMetadataProvider
|
public class OpenMovieDatabaseProvider : BaseMetadataProvider
|
||||||
{
|
{
|
||||||
private readonly SemaphoreSlim _resourcePool = new SemaphoreSlim(1, 1);
|
private readonly SemaphoreSlim _resourcePool = new SemaphoreSlim(2, 2);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the json serializer.
|
/// Gets the json serializer.
|
||||||
|
@ -35,7 +35,7 @@ namespace MediaBrowser.Controller.Providers.TV
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// The tv db
|
/// The tv db
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal readonly SemaphoreSlim TvDbResourcePool = new SemaphoreSlim(1, 1);
|
internal readonly SemaphoreSlim TvDbResourcePool = new SemaphoreSlim(2, 2);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the current.
|
/// Gets the current.
|
||||||
|
@ -1036,21 +1036,40 @@ namespace MediaBrowser.Server.Implementations.Library
|
|||||||
/// <param name="item">The item.</param>
|
/// <param name="item">The item.</param>
|
||||||
/// <param name="cancellationToken">The cancellation token.</param>
|
/// <param name="cancellationToken">The cancellation token.</param>
|
||||||
/// <returns>Task.</returns>
|
/// <returns>Task.</returns>
|
||||||
public async Task CreateItem(BaseItem item, CancellationToken cancellationToken)
|
public Task CreateItem(BaseItem item, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
await SaveItem(item, cancellationToken).ConfigureAwait(false);
|
return CreateItems(new[] { item }, cancellationToken);
|
||||||
|
}
|
||||||
|
|
||||||
UpdateItemInLibraryCache(item);
|
/// <summary>
|
||||||
|
/// Creates the items.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="items">The items.</param>
|
||||||
|
/// <param name="cancellationToken">The cancellation token.</param>
|
||||||
|
/// <returns>Task.</returns>
|
||||||
|
public async Task CreateItems(IEnumerable<BaseItem> items, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
var list = items.ToList();
|
||||||
|
|
||||||
|
await ItemRepository.SaveItems(list, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
|
foreach (var item in list)
|
||||||
|
{
|
||||||
|
UpdateItemInLibraryCache(item);
|
||||||
|
}
|
||||||
|
|
||||||
if (ItemAdded != null)
|
if (ItemAdded != null)
|
||||||
{
|
{
|
||||||
try
|
foreach (var item in list)
|
||||||
{
|
{
|
||||||
ItemAdded(this, new ItemChangeEventArgs { Item = item });
|
try
|
||||||
}
|
{
|
||||||
catch (Exception ex)
|
ItemAdded(this, new ItemChangeEventArgs { Item = item });
|
||||||
{
|
}
|
||||||
_logger.ErrorException("Error in ItemUpdated event handler", ex);
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.ErrorException("Error in ItemUpdated event handler", ex);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1063,7 +1082,7 @@ namespace MediaBrowser.Server.Implementations.Library
|
|||||||
/// <returns>Task.</returns>
|
/// <returns>Task.</returns>
|
||||||
public async Task UpdateItem(BaseItem item, CancellationToken cancellationToken)
|
public async Task UpdateItem(BaseItem item, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
await SaveItem(item, cancellationToken).ConfigureAwait(false);
|
await ItemRepository.SaveItem(item, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
UpdateItemInLibraryCache(item);
|
UpdateItemInLibraryCache(item);
|
||||||
|
|
||||||
@ -1099,17 +1118,6 @@ namespace MediaBrowser.Server.Implementations.Library
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Saves the item.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="item">The item.</param>
|
|
||||||
/// <param name="cancellationToken">The cancellation token.</param>
|
|
||||||
/// <returns>Task.</returns>
|
|
||||||
private Task SaveItem(BaseItem item, CancellationToken cancellationToken)
|
|
||||||
{
|
|
||||||
return ItemRepository.SaveItem(item, cancellationToken);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Retrieves the item.
|
/// Retrieves the item.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -135,7 +135,7 @@ namespace MediaBrowser.Server.Implementations.Sqlite
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// The _write lock
|
/// The _write lock
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private readonly SemaphoreSlim _writeLock = new SemaphoreSlim(1,1);
|
private readonly SemaphoreSlim _writeLock = new SemaphoreSlim(1, 1);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Prepares the statements.
|
/// Prepares the statements.
|
||||||
@ -172,13 +172,34 @@ namespace MediaBrowser.Server.Implementations.Sqlite
|
|||||||
/// <param name="cancellationToken">The cancellation token.</param>
|
/// <param name="cancellationToken">The cancellation token.</param>
|
||||||
/// <returns>Task.</returns>
|
/// <returns>Task.</returns>
|
||||||
/// <exception cref="System.ArgumentNullException">item</exception>
|
/// <exception cref="System.ArgumentNullException">item</exception>
|
||||||
public async Task SaveItem(BaseItem item, CancellationToken cancellationToken)
|
public Task SaveItem(BaseItem item, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
if (item == null)
|
if (item == null)
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException("item");
|
throw new ArgumentNullException("item");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return SaveItems(new[] { item }, cancellationToken);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Saves the items.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="items">The items.</param>
|
||||||
|
/// <param name="cancellationToken">The cancellation token.</param>
|
||||||
|
/// <returns>Task.</returns>
|
||||||
|
/// <exception cref="System.ArgumentNullException">
|
||||||
|
/// items
|
||||||
|
/// or
|
||||||
|
/// cancellationToken
|
||||||
|
/// </exception>
|
||||||
|
public async Task SaveItems(IEnumerable<BaseItem> items, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
if (items == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("items");
|
||||||
|
}
|
||||||
|
|
||||||
if (cancellationToken == null)
|
if (cancellationToken == null)
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException("cancellationToken");
|
throw new ArgumentNullException("cancellationToken");
|
||||||
@ -186,8 +207,6 @@ namespace MediaBrowser.Server.Implementations.Sqlite
|
|||||||
|
|
||||||
cancellationToken.ThrowIfCancellationRequested();
|
cancellationToken.ThrowIfCancellationRequested();
|
||||||
|
|
||||||
var serialized = _jsonSerializer.SerializeToBytes(item);
|
|
||||||
|
|
||||||
await _writeLock.WaitAsync(cancellationToken).ConfigureAwait(false);
|
await _writeLock.WaitAsync(cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
SQLiteTransaction transaction = null;
|
SQLiteTransaction transaction = null;
|
||||||
@ -196,13 +215,18 @@ namespace MediaBrowser.Server.Implementations.Sqlite
|
|||||||
{
|
{
|
||||||
transaction = Connection.BeginTransaction();
|
transaction = Connection.BeginTransaction();
|
||||||
|
|
||||||
_saveItemCommand.Parameters[0].Value = item.Id;
|
foreach (var item in items)
|
||||||
_saveItemCommand.Parameters[1].Value = item.GetType().FullName;
|
{
|
||||||
_saveItemCommand.Parameters[2].Value = serialized;
|
cancellationToken.ThrowIfCancellationRequested();
|
||||||
|
|
||||||
|
_saveItemCommand.Parameters[0].Value = item.Id;
|
||||||
|
_saveItemCommand.Parameters[1].Value = item.GetType().FullName;
|
||||||
|
_saveItemCommand.Parameters[2].Value = _jsonSerializer.SerializeToBytes(item);
|
||||||
|
|
||||||
_saveItemCommand.Transaction = transaction;
|
_saveItemCommand.Transaction = transaction;
|
||||||
|
|
||||||
await _saveItemCommand.ExecuteNonQueryAsync(cancellationToken);
|
await _saveItemCommand.ExecuteNonQueryAsync(cancellationToken);
|
||||||
|
}
|
||||||
|
|
||||||
transaction.Commit();
|
transaction.Commit();
|
||||||
}
|
}
|
||||||
@ -400,7 +424,7 @@ namespace MediaBrowser.Server.Implementations.Sqlite
|
|||||||
foreach (var child in children)
|
foreach (var child in children)
|
||||||
{
|
{
|
||||||
_saveChildrenCommand.Transaction = transaction;
|
_saveChildrenCommand.Transaction = transaction;
|
||||||
|
|
||||||
_saveChildrenCommand.Parameters[0].Value = id;
|
_saveChildrenCommand.Parameters[0].Value = id;
|
||||||
_saveChildrenCommand.Parameters[1].Value = child.Id;
|
_saveChildrenCommand.Parameters[1].Value = child.Id;
|
||||||
|
|
||||||
|
@ -1,11 +1,9 @@
|
|||||||
using MediaBrowser.Model.Logging;
|
using MediaBrowser.Model.Logging;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Concurrent;
|
|
||||||
using System.Data;
|
using System.Data;
|
||||||
using System.Data.Common;
|
using System.Data.Common;
|
||||||
using System.Data.SQLite;
|
using System.Data.SQLite;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Threading;
|
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace MediaBrowser.Server.Implementations.Sqlite
|
namespace MediaBrowser.Server.Implementations.Sqlite
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
<targets async="true"></targets>
|
<targets async="true"></targets>
|
||||||
</nlog>
|
</nlog>
|
||||||
<appSettings>
|
<appSettings>
|
||||||
<add key="DebugProgramDataPath" value="%ApplicationData%\MediaBrowser-Server" />
|
<add key="DebugProgramDataPath" value="..\..\..\..\ProgramData-Server" />
|
||||||
<add key="ReleaseProgramDataPath" value="%ApplicationData%" />
|
<add key="ReleaseProgramDataPath" value="%ApplicationData%" />
|
||||||
<add key="ProgramDataFolderName" value="MediaBrowser-Server" />
|
<add key="ProgramDataFolderName" value="MediaBrowser-Server" />
|
||||||
<add key="ClientSettingsProvider.ServiceUri" value="" />
|
<add key="ClientSettingsProvider.ServiceUri" value="" />
|
||||||
|
@ -114,9 +114,15 @@
|
|||||||
<Content Include="dashboard-ui\css\images\items\searchhints\tv.png">
|
<Content Include="dashboard-ui\css\images\items\searchhints\tv.png">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
|
<Content Include="dashboard-ui\css\images\media\mute.png">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
<Content Include="dashboard-ui\css\images\media\settings.png">
|
<Content Include="dashboard-ui\css\images\media\settings.png">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
|
<Content Include="dashboard-ui\css\images\media\volume.png">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
<Content Include="dashboard-ui\css\images\rotten.png">
|
<Content Include="dashboard-ui\css\images\rotten.png">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user