mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-07-04 21:32:53 +01:00
Split BaseItemRepository and IItemRepository
This commit is contained in:
@@ -36,6 +36,7 @@ public class CleanupOrphanedExtras : IAsyncMigrationRoutine
|
||||
/// <param name="dbContextFactory">The database context factory.</param>
|
||||
/// <param name="libraryManager">The library manager.</param>
|
||||
/// <param name="itemRepository">The item repository.</param>
|
||||
/// <param name="itemCountService">The item count service.</param>
|
||||
/// <param name="channelManager">The channel manager.</param>
|
||||
/// <param name="recordingsManager">The recordings manager.</param>
|
||||
/// <param name="mediaSourceManager">The media source manager.</param>
|
||||
@@ -46,6 +47,7 @@ public class CleanupOrphanedExtras : IAsyncMigrationRoutine
|
||||
IDbContextFactory<JellyfinDbContext> dbContextFactory,
|
||||
ILibraryManager libraryManager,
|
||||
IItemRepository itemRepository,
|
||||
IItemCountService itemCountService,
|
||||
IChannelManager channelManager,
|
||||
IRecordingsManager recordingsManager,
|
||||
IMediaSourceManager mediaSourceManager,
|
||||
@@ -57,6 +59,7 @@ public class CleanupOrphanedExtras : IAsyncMigrationRoutine
|
||||
_libraryManager = libraryManager;
|
||||
BaseItem.LibraryManager ??= libraryManager;
|
||||
BaseItem.ItemRepository ??= itemRepository;
|
||||
BaseItem.ItemCountService ??= itemCountService;
|
||||
BaseItem.ChannelManager ??= channelManager;
|
||||
BaseItem.MediaSourceManager ??= mediaSourceManager;
|
||||
BaseItem.MediaSegmentManager ??= mediaSegmentManager;
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using Jellyfin.Data.Enums;
|
||||
using MediaBrowser.Controller;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Entities.Audio;
|
||||
using MediaBrowser.Controller.Persistence;
|
||||
@@ -23,16 +19,19 @@ namespace Jellyfin.Server.Migrations.Routines
|
||||
#pragma warning restore CS0618 // Type or member is obsolete
|
||||
{
|
||||
private readonly ILogger<FixAudioData> _logger;
|
||||
private readonly IServerApplicationPaths _applicationPaths;
|
||||
private readonly IItemRepository _itemRepository;
|
||||
private readonly IItemCountService _countService;
|
||||
private readonly IItemPersistenceService _persistenceService;
|
||||
|
||||
public FixAudioData(
|
||||
IServerApplicationPaths applicationPaths,
|
||||
ILoggerFactory loggerFactory,
|
||||
IItemRepository itemRepository)
|
||||
IItemRepository itemRepository,
|
||||
IItemCountService countService,
|
||||
IItemPersistenceService persistenceService)
|
||||
{
|
||||
_applicationPaths = applicationPaths;
|
||||
_itemRepository = itemRepository;
|
||||
_countService = countService;
|
||||
_persistenceService = persistenceService;
|
||||
_logger = loggerFactory.CreateLogger<FixAudioData>();
|
||||
}
|
||||
|
||||
@@ -41,7 +40,7 @@ namespace Jellyfin.Server.Migrations.Routines
|
||||
{
|
||||
_logger.LogInformation("Backfilling audio lyrics data to database.");
|
||||
var startIndex = 0;
|
||||
var records = _itemRepository.GetCount(new InternalItemsQuery
|
||||
var records = _countService.GetCount(new InternalItemsQuery
|
||||
{
|
||||
IncludeItemTypes = [BaseItemKind.Audio],
|
||||
});
|
||||
@@ -68,7 +67,7 @@ namespace Jellyfin.Server.Migrations.Routines
|
||||
}
|
||||
}
|
||||
|
||||
_itemRepository.SaveItems(results, CancellationToken.None);
|
||||
_persistenceService.SaveItems(results, CancellationToken.None);
|
||||
startIndex += results.Count;
|
||||
_logger.LogInformation("Backfilled data for {UpdatedRecords} of {TotalRecords} audio records", startIndex, records);
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ public class FixIncorrectOwnerIdRelationships : IAsyncMigrationRoutine
|
||||
private readonly IStartupLogger<FixIncorrectOwnerIdRelationships> _logger;
|
||||
private readonly IDbContextFactory<JellyfinDbContext> _dbContextFactory;
|
||||
private readonly ILibraryManager _libraryManager;
|
||||
private readonly IItemRepository _itemRepository;
|
||||
private readonly IItemPersistenceService _persistenceService;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="FixIncorrectOwnerIdRelationships"/> class.
|
||||
@@ -32,17 +32,17 @@ public class FixIncorrectOwnerIdRelationships : IAsyncMigrationRoutine
|
||||
/// <param name="logger">The startup logger.</param>
|
||||
/// <param name="dbContextFactory">The database context factory.</param>
|
||||
/// <param name="libraryManager">The library manager.</param>
|
||||
/// <param name="itemRepository">The item repository.</param>
|
||||
/// <param name="persistenceService">The item persistence service.</param>
|
||||
public FixIncorrectOwnerIdRelationships(
|
||||
IStartupLogger<FixIncorrectOwnerIdRelationships> logger,
|
||||
IDbContextFactory<JellyfinDbContext> dbContextFactory,
|
||||
ILibraryManager libraryManager,
|
||||
IItemRepository itemRepository)
|
||||
IItemPersistenceService persistenceService)
|
||||
{
|
||||
_logger = logger;
|
||||
_dbContextFactory = dbContextFactory;
|
||||
_libraryManager = libraryManager;
|
||||
_itemRepository = itemRepository;
|
||||
_persistenceService = persistenceService;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
@@ -157,7 +157,7 @@ public class FixIncorrectOwnerIdRelationships : IAsyncMigrationRoutine
|
||||
{
|
||||
try
|
||||
{
|
||||
_itemRepository.DeleteItem([itemId]);
|
||||
_persistenceService.DeleteItem([itemId]);
|
||||
deletedCount++;
|
||||
_logger.LogInformation("Successfully deleted duplicate item {ItemId} at path {Path} via direct database deletion", itemId, path);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user