From 628c6cbc28f5a744785731dd4e94ec7a1f881dd2 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sat, 17 Jan 2015 13:15:09 -0500 Subject: [PATCH] make library scan a bit more hands off --- .../LiveTv/LiveTvChannel.cs | 20 +---- .../MediaBrowser.LocalMetadata.csproj | 2 - .../Providers/ChannelXmlProvider.cs | 30 ------- .../Savers/ChannelXmlSaver.cs | 81 ------------------- MediaBrowser.Model/Users/UserPolicy.cs | 2 + .../BoxSets/BoxSetMetadataService.cs | 42 +++++----- .../Manager/MetadataService.cs | 28 +++---- .../Music/AlbumMetadataService.cs | 76 ++++++++--------- .../Music/ArtistMetadataService.cs | 37 +++++---- .../TV/DummySeasonProvider.cs | 65 ++++++++++++++- .../TV/MissingEpisodeProvider.cs | 4 +- .../TV/SeasonMetadataService.cs | 14 +++- .../TV/SeriesMetadataService.cs | 21 ++++- .../TV/SeriesPostScanTask.cs | 2 +- .../Library/LibraryManager.cs | 70 ---------------- .../Resolvers/Audio/MusicAlbumResolver.cs | 3 +- .../Library/Validators/ArtistsPostScanTask.cs | 7 +- .../Library/Validators/ArtistsValidator.cs | 65 +-------------- .../Validators/GameGenresPostScanTask.cs | 8 +- .../Library/Validators/GameGenresValidator.cs | 15 +--- .../Library/Validators/GenresPostScanTask.cs | 8 +- .../Library/Validators/GenresValidator.cs | 15 +--- .../Validators/MusicGenresPostScanTask.cs | 8 +- .../Validators/MusicGenresValidator.cs | 7 +- .../Library/Validators/StudiosPostScanTask.cs | 8 +- .../Library/Validators/StudiosValidator.cs | 15 +--- .../Library/Validators/YearsPostScanTask.cs | 12 ++- .../LiveTv/LiveTvManager.cs | 25 +----- 28 files changed, 247 insertions(+), 443 deletions(-) delete mode 100644 MediaBrowser.LocalMetadata/Providers/ChannelXmlProvider.cs delete mode 100644 MediaBrowser.LocalMetadata/Savers/ChannelXmlSaver.cs diff --git a/MediaBrowser.Controller/LiveTv/LiveTvChannel.cs b/MediaBrowser.Controller/LiveTv/LiveTvChannel.cs index 459ead16cb..b4b9fa77b8 100644 --- a/MediaBrowser.Controller/LiveTv/LiveTvChannel.cs +++ b/MediaBrowser.Controller/LiveTv/LiveTvChannel.cs @@ -4,9 +4,9 @@ using MediaBrowser.Model.Dto; using MediaBrowser.Model.Entities; using MediaBrowser.Model.LiveTv; using MediaBrowser.Model.MediaInfo; +using MediaBrowser.Model.Users; using System.Collections.Generic; using System.Linq; -using MediaBrowser.Model.Users; namespace MediaBrowser.Controller.LiveTv { @@ -21,19 +21,6 @@ namespace MediaBrowser.Controller.LiveTv return GetClientTypeName() + "-" + Name; } - /// - /// Returns the folder containing the item. - /// If the item is a folder, it returns the folder itself - /// - /// The containing folder path. - public override string ContainingFolderPath - { - get - { - return Path; - } - } - protected override bool GetBlockUnratedValue(UserPolicy config) { return config.BlockUnratedItems.Contains(UnratedItem.LiveTvChannel); @@ -51,11 +38,6 @@ namespace MediaBrowser.Controller.LiveTv } } - public override bool IsSaveLocalMetadataEnabled() - { - return true; - } - /// /// Gets or sets the number. /// diff --git a/MediaBrowser.LocalMetadata/MediaBrowser.LocalMetadata.csproj b/MediaBrowser.LocalMetadata/MediaBrowser.LocalMetadata.csproj index cb9c23494a..894be87994 100644 --- a/MediaBrowser.LocalMetadata/MediaBrowser.LocalMetadata.csproj +++ b/MediaBrowser.LocalMetadata/MediaBrowser.LocalMetadata.csproj @@ -61,7 +61,6 @@ - @@ -74,7 +73,6 @@ - diff --git a/MediaBrowser.LocalMetadata/Providers/ChannelXmlProvider.cs b/MediaBrowser.LocalMetadata/Providers/ChannelXmlProvider.cs deleted file mode 100644 index 78845487a2..0000000000 --- a/MediaBrowser.LocalMetadata/Providers/ChannelXmlProvider.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System.IO; -using System.Threading; -using MediaBrowser.Common.IO; -using MediaBrowser.Controller.LiveTv; -using MediaBrowser.Controller.Providers; -using MediaBrowser.Model.Logging; - -namespace MediaBrowser.LocalMetadata.Providers -{ - public class ChannelXmlProvider : BaseXmlProvider - { - private readonly ILogger _logger; - - public ChannelXmlProvider(IFileSystem fileSystem, ILogger logger) - : base(fileSystem) - { - _logger = logger; - } - - protected override void Fetch(LocalMetadataResult result, string path, CancellationToken cancellationToken) - { - new BaseItemXmlParser(_logger).Fetch(result.Item, path, cancellationToken); - } - - protected override FileSystemInfo GetXmlFile(ItemInfo info, IDirectoryService directoryService) - { - return directoryService.GetFile(Path.Combine(info.Path, "channel.xml")); - } - } -} diff --git a/MediaBrowser.LocalMetadata/Savers/ChannelXmlSaver.cs b/MediaBrowser.LocalMetadata/Savers/ChannelXmlSaver.cs deleted file mode 100644 index 03fdf2bc80..0000000000 --- a/MediaBrowser.LocalMetadata/Savers/ChannelXmlSaver.cs +++ /dev/null @@ -1,81 +0,0 @@ -using MediaBrowser.Controller.Configuration; -using MediaBrowser.Controller.Entities; -using MediaBrowser.Controller.Library; -using MediaBrowser.Controller.LiveTv; -using System.Collections.Generic; -using System.IO; -using System.Text; -using System.Threading; - -namespace MediaBrowser.LocalMetadata.Savers -{ - /// - /// Class PersonXmlSaver - /// - public class ChannelXmlSaver : IMetadataFileSaver - { - private readonly IServerConfigurationManager _config; - - public ChannelXmlSaver(IServerConfigurationManager config) - { - _config = config; - } - - /// - /// Determines whether [is enabled for] [the specified item]. - /// - /// The item. - /// Type of the update. - /// true if [is enabled for] [the specified item]; otherwise, false. - public bool IsEnabledFor(IHasMetadata item, ItemUpdateType updateType) - { - if (!item.SupportsLocalMetadata) - { - return false; - } - - return item is LiveTvChannel && updateType >= ItemUpdateType.MetadataDownload; - } - - public string Name - { - get - { - return XmlProviderUtils.Name; - } - } - - /// - /// Saves the specified item. - /// - /// The item. - /// The cancellation token. - /// Task. - public void Save(IHasMetadata item, CancellationToken cancellationToken) - { - var builder = new StringBuilder(); - - builder.Append(""); - - XmlSaverHelpers.AddCommonNodes((LiveTvChannel)item, builder); - - builder.Append(""); - - var xmlFilePath = GetSavePath(item); - - XmlSaverHelpers.Save(builder, xmlFilePath, new List - { - }, _config); - } - - /// - /// Gets the save path. - /// - /// The item. - /// System.String. - public string GetSavePath(IHasMetadata item) - { - return Path.Combine(item.Path, "channel.xml"); - } - } -} diff --git a/MediaBrowser.Model/Users/UserPolicy.cs b/MediaBrowser.Model/Users/UserPolicy.cs index 12b8c40715..eb8dbc6f0b 100644 --- a/MediaBrowser.Model/Users/UserPolicy.cs +++ b/MediaBrowser.Model/Users/UserPolicy.cs @@ -62,6 +62,8 @@ namespace MediaBrowser.Model.Users EnableLiveTvAccess = true; EnableSharedDeviceControl = true; + EnabledChannels = new string[] { }; + BlockedMediaFolders = new string[] { }; BlockedTags = new string[] { }; BlockUnratedItems = new UnratedItem[] { }; diff --git a/MediaBrowser.Providers/BoxSets/BoxSetMetadataService.cs b/MediaBrowser.Providers/BoxSets/BoxSetMetadataService.cs index 5afaaa8753..5e16ed69cf 100644 --- a/MediaBrowser.Providers/BoxSets/BoxSetMetadataService.cs +++ b/MediaBrowser.Providers/BoxSets/BoxSetMetadataService.cs @@ -12,6 +12,7 @@ using MediaBrowser.Providers.Manager; using System; using System.Collections.Generic; using System.Linq; +using System.Threading.Tasks; namespace MediaBrowser.Providers.BoxSets { @@ -51,31 +52,34 @@ namespace MediaBrowser.Providers.BoxSets } } - protected override ItemUpdateType BeforeSave(BoxSet item) + protected override async Task BeforeSave(BoxSet item, bool isFullRefresh, ItemUpdateType currentUpdateType) { - var updateType = base.BeforeSave(item); + var updateType = await base.BeforeSave(item, isFullRefresh, currentUpdateType).ConfigureAwait(false); - if (!item.LockedFields.Contains(MetadataFields.OfficialRating)) + if (isFullRefresh || currentUpdateType > ItemUpdateType.None) { - var currentOfficialRating = item.OfficialRating; + if (!item.LockedFields.Contains(MetadataFields.OfficialRating)) + { + var currentOfficialRating = item.OfficialRating; - // Gather all possible ratings - var ratings = item.RecursiveChildren - .Concat(item.GetLinkedChildren()) - .Where(i => i is Movie || i is Series) - .Select(i => i.OfficialRating) - .Where(i => !string.IsNullOrEmpty(i)) - .Distinct(StringComparer.OrdinalIgnoreCase) - .Select(i => new Tuple(i, _iLocalizationManager.GetRatingLevel(i))) - .OrderBy(i => i.Item2 ?? 1000) - .Select(i => i.Item1); + // Gather all possible ratings + var ratings = item.RecursiveChildren + .Concat(item.GetLinkedChildren()) + .Where(i => i is Movie || i is Series) + .Select(i => i.OfficialRating) + .Where(i => !string.IsNullOrEmpty(i)) + .Distinct(StringComparer.OrdinalIgnoreCase) + .Select(i => new Tuple(i, _iLocalizationManager.GetRatingLevel(i))) + .OrderBy(i => i.Item2 ?? 1000) + .Select(i => i.Item1); - item.OfficialRating = ratings.FirstOrDefault() ?? item.OfficialRating; + item.OfficialRating = ratings.FirstOrDefault() ?? item.OfficialRating; - if (!string.Equals(currentOfficialRating ?? string.Empty, item.OfficialRating ?? string.Empty, - StringComparison.OrdinalIgnoreCase)) - { - updateType = updateType | ItemUpdateType.MetadataEdit; + if (!string.Equals(currentOfficialRating ?? string.Empty, item.OfficialRating ?? string.Empty, + StringComparison.OrdinalIgnoreCase)) + { + updateType = updateType | ItemUpdateType.MetadataEdit; + } } } diff --git a/MediaBrowser.Providers/Manager/MetadataService.cs b/MediaBrowser.Providers/Manager/MetadataService.cs index e27c39df13..f55eddfcf1 100644 --- a/MediaBrowser.Providers/Manager/MetadataService.cs +++ b/MediaBrowser.Providers/Manager/MetadataService.cs @@ -163,14 +163,13 @@ namespace MediaBrowser.Providers.Manager } } - updateType = updateType | BeforeSave(itemOfType); - - var providersHadChanges = updateType > ItemUpdateType.None; + updateType = updateType | (await BeforeSave(itemOfType, item.DateLastSaved == default(DateTime) || refreshOptions.ReplaceAllMetadata, updateType).ConfigureAwait(false)); // Save if changes were made, or it's never been saved before - if (refreshOptions.ForceSave || providersHadChanges || item.DateLastSaved == default(DateTime) || refreshOptions.ReplaceAllMetadata) + if (refreshOptions.ForceSave || updateType > ItemUpdateType.None || item.DateLastSaved == default(DateTime) || refreshOptions.ReplaceAllMetadata) { - if (refreshOptions.ForceSave || providersHadChanges || refreshOptions.ReplaceAllMetadata) + // If any of these properties are set then make sure the updateType is not None, just to force everything to save + if (refreshOptions.ForceSave || refreshOptions.ReplaceAllMetadata) { updateType = updateType | ItemUpdateType.MetadataDownload; } @@ -179,7 +178,7 @@ namespace MediaBrowser.Providers.Manager await SaveItem(itemOfType, updateType, cancellationToken); } - if (providersHadChanges || refreshResult.IsDirty) + if (updateType > ItemUpdateType.None || refreshResult.IsDirty) { await SaveProviderResult(itemOfType, refreshResult, refreshOptions.DirectoryService).ConfigureAwait(false); } @@ -194,14 +193,17 @@ namespace MediaBrowser.Providers.Manager } } + private readonly Task _cachedResult = Task.FromResult(ItemUpdateType.None); /// /// Befores the save. /// /// The item. + /// if set to true [is full refresh]. + /// Type of the current update. /// ItemUpdateType. - protected virtual ItemUpdateType BeforeSave(TItemType item) + protected virtual Task BeforeSave(TItemType item, bool isFullRefresh, ItemUpdateType currentUpdateType) { - return ItemUpdateType.None; + return _cachedResult; } /// @@ -549,11 +551,6 @@ namespace MediaBrowser.Providers.Manager } } - if (refreshResult.Successes > 0) - { - AfterRemoteRefresh(temp); - } - return refreshResult; } @@ -570,11 +567,6 @@ namespace MediaBrowser.Providers.Manager } } - protected virtual void AfterRemoteRefresh(TItemType item) - { - - } - private async Task CreateInitialLookupInfo(TItemType item, CancellationToken cancellationToken) { var info = item.GetLookupInfo(); diff --git a/MediaBrowser.Providers/Music/AlbumMetadataService.cs b/MediaBrowser.Providers/Music/AlbumMetadataService.cs index 6e3a5bf063..64dcd913d8 100644 --- a/MediaBrowser.Providers/Music/AlbumMetadataService.cs +++ b/MediaBrowser.Providers/Music/AlbumMetadataService.cs @@ -9,6 +9,7 @@ using MediaBrowser.Providers.Manager; using System; using System.Collections.Generic; using System.Linq; +using System.Threading.Tasks; namespace MediaBrowser.Providers.Music { @@ -36,59 +37,62 @@ namespace MediaBrowser.Providers.Music } } - protected override ItemUpdateType BeforeSave(MusicAlbum item) + protected override async Task BeforeSave(MusicAlbum item, bool isFullRefresh, ItemUpdateType currentUpdateType) { - var updateType = base.BeforeSave(item); + var updateType = await base.BeforeSave(item, isFullRefresh, currentUpdateType).ConfigureAwait(false); - var songs = item.RecursiveChildren.OfType private readonly ILibraryManager _libraryManager; + private readonly ILogger _logger; /// /// Initializes a new instance of the class. /// /// The library manager. - public GameGenresPostScanTask(ILibraryManager libraryManager) + /// The logger. + public GameGenresPostScanTask(ILibraryManager libraryManager, ILogger logger) { _libraryManager = libraryManager; + _logger = logger; } /// @@ -32,7 +36,7 @@ namespace MediaBrowser.Server.Implementations.Library.Validators /// Task. public Task Run(IProgress progress, CancellationToken cancellationToken) { - return ((LibraryManager)_libraryManager).ValidateGameGenres(cancellationToken, progress); + return new GameGenresValidator(_libraryManager, _logger).Run(progress, cancellationToken); } } } diff --git a/MediaBrowser.Server.Implementations/Library/Validators/GameGenresValidator.cs b/MediaBrowser.Server.Implementations/Library/Validators/GameGenresValidator.cs index 6b658e175d..b2f2a60c24 100644 --- a/MediaBrowser.Server.Implementations/Library/Validators/GameGenresValidator.cs +++ b/MediaBrowser.Server.Implementations/Library/Validators/GameGenresValidator.cs @@ -15,20 +15,14 @@ namespace MediaBrowser.Server.Implementations.Library.Validators /// private readonly ILibraryManager _libraryManager; - /// - /// The _user manager - /// - private readonly IUserManager _userManager; - /// /// The _logger /// private readonly ILogger _logger; - public GameGenresValidator(ILibraryManager libraryManager, IUserManager userManager, ILogger logger) + public GameGenresValidator(ILibraryManager libraryManager, ILogger logger) { _libraryManager = libraryManager; - _userManager = userManager; _logger = logger; } @@ -45,14 +39,11 @@ namespace MediaBrowser.Server.Implementations.Library.Validators .Distinct(StringComparer.OrdinalIgnoreCase) .ToList(); - progress.Report(2); var numComplete = 0; var count = items.Count; foreach (var name in items) { - cancellationToken.ThrowIfCancellationRequested(); - try { var itemByName = _libraryManager.GetGameGenre(name); @@ -72,9 +63,9 @@ namespace MediaBrowser.Server.Implementations.Library.Validators numComplete++; double percent = numComplete; percent /= count; - percent *= 90; + percent *= 100; - progress.Report(percent + 10); + progress.Report(percent); } progress.Report(100); diff --git a/MediaBrowser.Server.Implementations/Library/Validators/GenresPostScanTask.cs b/MediaBrowser.Server.Implementations/Library/Validators/GenresPostScanTask.cs index f1d0ef3706..a1c34676c8 100644 --- a/MediaBrowser.Server.Implementations/Library/Validators/GenresPostScanTask.cs +++ b/MediaBrowser.Server.Implementations/Library/Validators/GenresPostScanTask.cs @@ -2,6 +2,7 @@ using System; using System.Threading; using System.Threading.Tasks; +using MediaBrowser.Model.Logging; namespace MediaBrowser.Server.Implementations.Library.Validators { @@ -11,14 +12,17 @@ namespace MediaBrowser.Server.Implementations.Library.Validators /// The _library manager /// private readonly ILibraryManager _libraryManager; + private readonly ILogger _logger; /// /// Initializes a new instance of the class. /// /// The library manager. - public GenresPostScanTask(ILibraryManager libraryManager) + /// The logger. + public GenresPostScanTask(ILibraryManager libraryManager, ILogger logger) { _libraryManager = libraryManager; + _logger = logger; } /// @@ -29,7 +33,7 @@ namespace MediaBrowser.Server.Implementations.Library.Validators /// Task. public Task Run(IProgress progress, CancellationToken cancellationToken) { - return ((LibraryManager)_libraryManager).ValidateGenres(cancellationToken, progress); + return new GenresValidator(_libraryManager, _logger).Run(progress, cancellationToken); } } } diff --git a/MediaBrowser.Server.Implementations/Library/Validators/GenresValidator.cs b/MediaBrowser.Server.Implementations/Library/Validators/GenresValidator.cs index b0dee9aaf3..43dc69e63c 100644 --- a/MediaBrowser.Server.Implementations/Library/Validators/GenresValidator.cs +++ b/MediaBrowser.Server.Implementations/Library/Validators/GenresValidator.cs @@ -16,20 +16,14 @@ namespace MediaBrowser.Server.Implementations.Library.Validators /// private readonly ILibraryManager _libraryManager; - /// - /// The _user manager - /// - private readonly IUserManager _userManager; - /// /// The _logger /// private readonly ILogger _logger; - public GenresValidator(ILibraryManager libraryManager, IUserManager userManager, ILogger logger) + public GenresValidator(ILibraryManager libraryManager, ILogger logger) { _libraryManager = libraryManager; - _userManager = userManager; _logger = logger; } @@ -46,14 +40,11 @@ namespace MediaBrowser.Server.Implementations.Library.Validators .Distinct(StringComparer.OrdinalIgnoreCase) .ToList(); - progress.Report(2); var numComplete = 0; var count = items.Count; foreach (var name in items) { - cancellationToken.ThrowIfCancellationRequested(); - try { var itemByName = _libraryManager.GetGenre(name); @@ -73,9 +64,9 @@ namespace MediaBrowser.Server.Implementations.Library.Validators numComplete++; double percent = numComplete; percent /= count; - percent *= 90; + percent *= 100; - progress.Report(percent + 10); + progress.Report(percent); } progress.Report(100); diff --git a/MediaBrowser.Server.Implementations/Library/Validators/MusicGenresPostScanTask.cs b/MediaBrowser.Server.Implementations/Library/Validators/MusicGenresPostScanTask.cs index 280dd90f46..dbcab0832a 100644 --- a/MediaBrowser.Server.Implementations/Library/Validators/MusicGenresPostScanTask.cs +++ b/MediaBrowser.Server.Implementations/Library/Validators/MusicGenresPostScanTask.cs @@ -1,4 +1,5 @@ using MediaBrowser.Controller.Library; +using MediaBrowser.Model.Logging; using System; using System.Threading; using System.Threading.Tasks; @@ -14,14 +15,17 @@ namespace MediaBrowser.Server.Implementations.Library.Validators /// The _library manager /// private readonly ILibraryManager _libraryManager; + private readonly ILogger _logger; /// /// Initializes a new instance of the class. /// /// The library manager. - public MusicGenresPostScanTask(ILibraryManager libraryManager) + /// The logger. + public MusicGenresPostScanTask(ILibraryManager libraryManager, ILogger logger) { _libraryManager = libraryManager; + _logger = logger; } /// @@ -32,7 +36,7 @@ namespace MediaBrowser.Server.Implementations.Library.Validators /// Task. public Task Run(IProgress progress, CancellationToken cancellationToken) { - return ((LibraryManager)_libraryManager).ValidateMusicGenres(cancellationToken, progress); + return new MusicGenresValidator(_libraryManager, _logger).Run(progress, cancellationToken); } } } diff --git a/MediaBrowser.Server.Implementations/Library/Validators/MusicGenresValidator.cs b/MediaBrowser.Server.Implementations/Library/Validators/MusicGenresValidator.cs index aa6c6281ee..dfdbda1d96 100644 --- a/MediaBrowser.Server.Implementations/Library/Validators/MusicGenresValidator.cs +++ b/MediaBrowser.Server.Implementations/Library/Validators/MusicGenresValidator.cs @@ -39,14 +39,11 @@ namespace MediaBrowser.Server.Implementations.Library.Validators .Distinct(StringComparer.OrdinalIgnoreCase) .ToList(); - progress.Report(2); var numComplete = 0; var count = items.Count; foreach (var name in items) { - cancellationToken.ThrowIfCancellationRequested(); - try { var itemByName = _libraryManager.GetMusicGenre(name); @@ -66,9 +63,9 @@ namespace MediaBrowser.Server.Implementations.Library.Validators numComplete++; double percent = numComplete; percent /= count; - percent *= 90; + percent *= 100; - progress.Report(percent + 10); + progress.Report(percent); } progress.Report(100); diff --git a/MediaBrowser.Server.Implementations/Library/Validators/StudiosPostScanTask.cs b/MediaBrowser.Server.Implementations/Library/Validators/StudiosPostScanTask.cs index 0f998b0708..0ff609da15 100644 --- a/MediaBrowser.Server.Implementations/Library/Validators/StudiosPostScanTask.cs +++ b/MediaBrowser.Server.Implementations/Library/Validators/StudiosPostScanTask.cs @@ -1,4 +1,5 @@ using MediaBrowser.Controller.Library; +using MediaBrowser.Model.Logging; using System; using System.Threading; using System.Threading.Tasks; @@ -15,13 +16,16 @@ namespace MediaBrowser.Server.Implementations.Library.Validators /// private readonly ILibraryManager _libraryManager; + private readonly ILogger _logger; + /// /// Initializes a new instance of the class. /// /// The library manager. - public StudiosPostScanTask(ILibraryManager libraryManager) + public StudiosPostScanTask(ILibraryManager libraryManager, ILogger logger) { _libraryManager = libraryManager; + _logger = logger; } /// @@ -32,7 +36,7 @@ namespace MediaBrowser.Server.Implementations.Library.Validators /// Task. public Task Run(IProgress progress, CancellationToken cancellationToken) { - return ((LibraryManager)_libraryManager).ValidateStudios(cancellationToken, progress); + return new StudiosValidator(_libraryManager, _logger).Run(progress, cancellationToken); } } } diff --git a/MediaBrowser.Server.Implementations/Library/Validators/StudiosValidator.cs b/MediaBrowser.Server.Implementations/Library/Validators/StudiosValidator.cs index a2ec9788c7..643deef014 100644 --- a/MediaBrowser.Server.Implementations/Library/Validators/StudiosValidator.cs +++ b/MediaBrowser.Server.Implementations/Library/Validators/StudiosValidator.cs @@ -14,20 +14,14 @@ namespace MediaBrowser.Server.Implementations.Library.Validators /// private readonly ILibraryManager _libraryManager; - /// - /// The _user manager - /// - private readonly IUserManager _userManager; - /// /// The _logger /// private readonly ILogger _logger; - public StudiosValidator(ILibraryManager libraryManager, IUserManager userManager, ILogger logger) + public StudiosValidator(ILibraryManager libraryManager, ILogger logger) { _libraryManager = libraryManager; - _userManager = userManager; _logger = logger; } @@ -44,14 +38,11 @@ namespace MediaBrowser.Server.Implementations.Library.Validators .Distinct(StringComparer.OrdinalIgnoreCase) .ToList(); - progress.Report(2); var numComplete = 0; var count = items.Count; foreach (var name in items) { - cancellationToken.ThrowIfCancellationRequested(); - try { var itemByName = _libraryManager.GetStudio(name); @@ -71,9 +62,9 @@ namespace MediaBrowser.Server.Implementations.Library.Validators numComplete++; double percent = numComplete; percent /= count; - percent *= 90; + percent *= 100; - progress.Report(percent + 10); + progress.Report(percent); } progress.Report(100); diff --git a/MediaBrowser.Server.Implementations/Library/Validators/YearsPostScanTask.cs b/MediaBrowser.Server.Implementations/Library/Validators/YearsPostScanTask.cs index 78783db90a..5b8f27f58a 100644 --- a/MediaBrowser.Server.Implementations/Library/Validators/YearsPostScanTask.cs +++ b/MediaBrowser.Server.Implementations/Library/Validators/YearsPostScanTask.cs @@ -26,17 +26,15 @@ namespace MediaBrowser.Server.Implementations.Library.Validators .Distinct() .ToList(); - progress.Report(10); - var count = allYears.Count; var numComplete = 0; foreach (var yearNumber in allYears) { - var year = _libraryManager.GetYear(yearNumber); - try { + var year = _libraryManager.GetYear(yearNumber); + await year.RefreshMetadata(cancellationToken).ConfigureAwait(false); } catch (OperationCanceledException) @@ -46,15 +44,15 @@ namespace MediaBrowser.Server.Implementations.Library.Validators } catch (Exception ex) { - _logger.ErrorException("Error refreshing year {0}", ex, year); + _logger.ErrorException("Error refreshing year {0}", ex, yearNumber); } numComplete++; double percent = numComplete; percent /= count; - percent *= 90; + percent *= 100; - progress.Report(percent + 10); + progress.Report(percent); } } } diff --git a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs index 96498563e6..74069e5801 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs @@ -436,40 +436,19 @@ namespace MediaBrowser.Server.Implementations.LiveTv private async Task GetChannel(ChannelInfo channelInfo, string serviceName, CancellationToken cancellationToken) { - var path = Path.Combine(_config.ApplicationPaths.ItemsByNamePath, "tvchannels", _fileSystem.GetValidFilename(channelInfo.Name)); - - var fileInfo = new DirectoryInfo(path); - var isNew = false; - if (!fileInfo.Exists) - { - _logger.Debug("Creating directory {0}", path); - - Directory.CreateDirectory(path); - fileInfo = new DirectoryInfo(path); - - if (!fileInfo.Exists) - { - throw new IOException("Path not created: " + path); - } - - isNew = true; - } - var id = _tvDtoService.GetInternalChannelId(serviceName, channelInfo.Id); var item = _itemRepo.RetrieveItem(id) as LiveTvChannel; - if (item == null || !string.Equals(item.Path, path, StringComparison.OrdinalIgnoreCase)) + if (item == null) { item = new LiveTvChannel { Name = channelInfo.Name, Id = id, - DateCreated = _fileSystem.GetCreationTimeUtc(fileInfo), - DateModified = _fileSystem.GetLastWriteTimeUtc(fileInfo), - Path = path + DateCreated = DateTime.UtcNow, }; isNew = true;