diff options
| author | Cody Robibero <cody@robibe.ro> | 2024-01-12 09:27:47 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-01-12 09:27:47 -0700 |
| commit | 82df226246515991b5a7dac576972ee4e6c0a646 (patch) | |
| tree | 6930d17b58bd9a422645cec3abaccaf551881150 /Emby.Server.Implementations/Channels/ChannelPostScanTask.cs | |
| parent | 68fd9c469f013acef3e661d15adb61c4eb965ec7 (diff) | |
| parent | 41de6d17411a3e5cb962da06c18ffb2a69b40849 (diff) | |
Merge pull request #10838 from barronpm/livetv-project
Move Live TV code to Jellyfin.LiveTv
Diffstat (limited to 'Emby.Server.Implementations/Channels/ChannelPostScanTask.cs')
| -rw-r--r-- | Emby.Server.Implementations/Channels/ChannelPostScanTask.cs | 100 |
1 files changed, 0 insertions, 100 deletions
diff --git a/Emby.Server.Implementations/Channels/ChannelPostScanTask.cs b/Emby.Server.Implementations/Channels/ChannelPostScanTask.cs deleted file mode 100644 index b358ba4d5..000000000 --- a/Emby.Server.Implementations/Channels/ChannelPostScanTask.cs +++ /dev/null @@ -1,100 +0,0 @@ -using System; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; -using Jellyfin.Data.Enums; -using MediaBrowser.Controller.Channels; -using MediaBrowser.Controller.Entities; -using MediaBrowser.Controller.Library; -using Microsoft.Extensions.Logging; - -namespace Emby.Server.Implementations.Channels -{ - /// <summary> - /// A task to remove all non-installed channels from the database. - /// </summary> - public class ChannelPostScanTask - { - private readonly IChannelManager _channelManager; - private readonly ILogger _logger; - private readonly ILibraryManager _libraryManager; - - /// <summary> - /// Initializes a new instance of the <see cref="ChannelPostScanTask"/> class. - /// </summary> - /// <param name="channelManager">The channel manager.</param> - /// <param name="logger">The logger.</param> - /// <param name="libraryManager">The library manager.</param> - public ChannelPostScanTask(IChannelManager channelManager, ILogger logger, ILibraryManager libraryManager) - { - _channelManager = channelManager; - _logger = logger; - _libraryManager = libraryManager; - } - - /// <summary> - /// Runs this task. - /// </summary> - /// <param name="progress">The progress.</param> - /// <param name="cancellationToken">The cancellation token.</param> - /// <returns>The completed task.</returns> - public Task Run(IProgress<double> progress, CancellationToken cancellationToken) - { - CleanDatabase(cancellationToken); - - progress.Report(100); - return Task.CompletedTask; - } - - private void CleanDatabase(CancellationToken cancellationToken) - { - var installedChannelIds = ((ChannelManager)_channelManager).GetInstalledChannelIds(); - - var uninstalledChannels = _libraryManager.GetItemList(new InternalItemsQuery - { - IncludeItemTypes = new[] { BaseItemKind.Channel }, - ExcludeItemIds = installedChannelIds.ToArray() - }); - - foreach (var channel in uninstalledChannels) - { - cancellationToken.ThrowIfCancellationRequested(); - - CleanChannel((Channel)channel, cancellationToken); - } - } - - private void CleanChannel(Channel channel, CancellationToken cancellationToken) - { - _logger.LogInformation("Cleaning channel {0} from database", channel.Id); - - // Delete all channel items - var items = _libraryManager.GetItemList(new InternalItemsQuery - { - ChannelIds = new[] { channel.Id } - }); - - foreach (var item in items) - { - cancellationToken.ThrowIfCancellationRequested(); - - _libraryManager.DeleteItem( - item, - new DeleteOptions - { - DeleteFileLocation = false - }, - false); - } - - // Finally, delete the channel itself - _libraryManager.DeleteItem( - channel, - new DeleteOptions - { - DeleteFileLocation = false - }, - false); - } - } -} |
