From 1a9e2dfd83dbab2e9a5f277229c5994253fd8a9a Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Mon, 17 Feb 2014 16:35:08 -0500 Subject: fixed themoviedb search returning no results --- .../Dto/DtoService.cs | 2 +- .../EntryPoints/LibraryChangedNotifier.cs | 15 +++++++ .../Library/CoreResolutionIgnoreRule.cs | 20 ++++----- .../Library/LibraryManager.cs | 3 +- .../Library/Validators/CountHelpers.cs | 52 +++++++++++----------- .../Persistence/SqliteMediaStreamsRepository.cs | 10 +++++ .../Persistence/SqliteShrinkMemoryTimer.cs | 2 +- 7 files changed, 65 insertions(+), 39 deletions(-) (limited to 'MediaBrowser.Server.Implementations') diff --git a/MediaBrowser.Server.Implementations/Dto/DtoService.cs b/MediaBrowser.Server.Implementations/Dto/DtoService.cs index ae08a7c3d..aba8c3353 100644 --- a/MediaBrowser.Server.Implementations/Dto/DtoService.cs +++ b/MediaBrowser.Server.Implementations/Dto/DtoService.cs @@ -902,7 +902,7 @@ namespace MediaBrowser.Server.Implementations.Dto { var locationType = item.LocationType; - if (locationType == LocationType.FileSystem || locationType == LocationType.Offline) + if (locationType != LocationType.Remote && locationType != LocationType.Virtual) { dto.Path = GetMappedPath(item.Path); } diff --git a/MediaBrowser.Server.Implementations/EntryPoints/LibraryChangedNotifier.cs b/MediaBrowser.Server.Implementations/EntryPoints/LibraryChangedNotifier.cs index a91033839..2928363e3 100644 --- a/MediaBrowser.Server.Implementations/EntryPoints/LibraryChangedNotifier.cs +++ b/MediaBrowser.Server.Implementations/EntryPoints/LibraryChangedNotifier.cs @@ -69,6 +69,11 @@ namespace MediaBrowser.Server.Implementations.EntryPoints /// The instance containing the event data. void libraryManager_ItemAdded(object sender, ItemChangeEventArgs e) { + if (e.Item.LocationType == LocationType.Virtual) + { + return; + } + lock (_libraryChangedSyncLock) { if (LibraryUpdateTimer == null) @@ -97,6 +102,11 @@ namespace MediaBrowser.Server.Implementations.EntryPoints /// The instance containing the event data. void libraryManager_ItemUpdated(object sender, ItemChangeEventArgs e) { + if (e.Item.LocationType == LocationType.Virtual) + { + return; + } + lock (_libraryChangedSyncLock) { if (LibraryUpdateTimer == null) @@ -120,6 +130,11 @@ namespace MediaBrowser.Server.Implementations.EntryPoints /// The instance containing the event data. void libraryManager_ItemRemoved(object sender, ItemChangeEventArgs e) { + if (e.Item.LocationType == LocationType.Virtual) + { + return; + } + lock (_libraryChangedSyncLock) { if (LibraryUpdateTimer == null) diff --git a/MediaBrowser.Server.Implementations/Library/CoreResolutionIgnoreRule.cs b/MediaBrowser.Server.Implementations/Library/CoreResolutionIgnoreRule.cs index 98a87d03d..c830c13b8 100644 --- a/MediaBrowser.Server.Implementations/Library/CoreResolutionIgnoreRule.cs +++ b/MediaBrowser.Server.Implementations/Library/CoreResolutionIgnoreRule.cs @@ -17,17 +17,15 @@ namespace MediaBrowser.Server.Implementations.Library /// /// Any folder named in this list will be ignored - can be added to at runtime for extensibility /// - private static readonly Dictionary IgnoreFolders = new List + private static readonly Dictionary IgnoreFolders = new List { - "metadata", - "certificate", - "backup", - "ps3_update", - "ps3_vprm", - "adv_obj", - "extrafanart", - "extrathumbs", - ".actors" + "metadata", + "ps3_update", + "ps3_vprm", + "extrafanart", + "extrathumbs", + ".actors", + ".wd_tv" }.ToDictionary(i => i, StringComparer.OrdinalIgnoreCase); @@ -51,7 +49,7 @@ namespace MediaBrowser.Server.Implementations.Library // https://github.com/MediaBrowser/MediaBrowser/issues/427 if (filename.IndexOf("._", StringComparison.OrdinalIgnoreCase) == 0) { - return true; + return true; } // Ignore hidden files and folders diff --git a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs b/MediaBrowser.Server.Implementations/Library/LibraryManager.cs index b42541204..a06e03c4a 100644 --- a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs +++ b/MediaBrowser.Server.Implementations/Library/LibraryManager.cs @@ -1312,7 +1312,8 @@ namespace MediaBrowser.Server.Implementations.Library /// Task. public async Task UpdateItem(BaseItem item, ItemUpdateType updateReason, CancellationToken cancellationToken) { - if (item.LocationType == LocationType.FileSystem) + var locationType = item.LocationType; + if (locationType != LocationType.Remote && locationType != LocationType.Virtual) { await _providerManagerFactory().SaveMetadata(item, updateReason).ConfigureAwait(false); } diff --git a/MediaBrowser.Server.Implementations/Library/Validators/CountHelpers.cs b/MediaBrowser.Server.Implementations/Library/Validators/CountHelpers.cs index 679eadb12..edb4e7382 100644 --- a/MediaBrowser.Server.Implementations/Library/Validators/CountHelpers.cs +++ b/MediaBrowser.Server.Implementations/Library/Validators/CountHelpers.cs @@ -13,51 +13,46 @@ namespace MediaBrowser.Server.Implementations.Library.Validators /// internal static class CountHelpers { - /// - /// Adds to dictionary. - /// - /// The item. - /// The counts. - internal static void AddToDictionary(BaseItem item, Dictionary counts) + private static CountType? GetCountType(BaseItem item) { if (item is Movie) { - IncrementCount(counts, CountType.Movie); + return CountType.Movie; } - else if (item is Trailer) + if (item is Episode) { - IncrementCount(counts, CountType.Trailer); + return CountType.Episode; } - else if (item is Series) + if (item is Game) { - IncrementCount(counts, CountType.Series); + return CountType.Game; } - else if (item is Game) + if (item is Audio) { - IncrementCount(counts, CountType.Game); + return CountType.Song; } - else if (item is Audio) + if (item is Trailer) { - IncrementCount(counts, CountType.Song); + return CountType.Trailer; } - else if (item is MusicAlbum) + if (item is Series) { - IncrementCount(counts, CountType.MusicAlbum); + return CountType.Series; } - else if (item is Episode) + if (item is MusicAlbum) { - IncrementCount(counts, CountType.Episode); + return CountType.MusicAlbum; } - else if (item is MusicVideo) + if (item is MusicVideo) { - IncrementCount(counts, CountType.MusicVideo); + return CountType.MusicVideo; } - else if (item is AdultVideo) + if (item is AdultVideo) { - IncrementCount(counts, CountType.AdultVideo); + return CountType.AdultVideo; } - IncrementCount(counts, CountType.Total); + return null; } /// @@ -129,6 +124,8 @@ namespace MediaBrowser.Server.Implementations.Library.Validators /// The master dictionary. internal static void SetItemCounts(Guid userId, BaseItem media, IEnumerable names, Dictionary>> masterDictionary) { + var countType = GetCountType(media); + foreach (var name in names) { Dictionary> libraryCounts; @@ -148,7 +145,12 @@ namespace MediaBrowser.Server.Implementations.Library.Validators libraryCounts.Add(userLibId, userDictionary); } - AddToDictionary(media, userDictionary); + if (countType.HasValue) + { + IncrementCount(userDictionary, countType.Value); + } + + IncrementCount(userDictionary, CountType.Total); } } } diff --git a/MediaBrowser.Server.Implementations/Persistence/SqliteMediaStreamsRepository.cs b/MediaBrowser.Server.Implementations/Persistence/SqliteMediaStreamsRepository.cs index b898398d8..f4e7fd0a6 100644 --- a/MediaBrowser.Server.Implementations/Persistence/SqliteMediaStreamsRepository.cs +++ b/MediaBrowser.Server.Implementations/Persistence/SqliteMediaStreamsRepository.cs @@ -19,6 +19,8 @@ namespace MediaBrowser.Server.Implementations.Persistence private IDbCommand _deleteStreamsCommand; private IDbCommand _saveStreamCommand; + private SqliteShrinkMemoryTimer _shrinkMemoryTimer; + public SqliteMediaStreamsRepository(IDbConnection connection, ILogManager logManager) { _connection = connection; @@ -51,6 +53,8 @@ namespace MediaBrowser.Server.Implementations.Persistence _connection.RunQueries(queries, _logger); PrepareStatements(); + + _shrinkMemoryTimer = new SqliteShrinkMemoryTimer(_connection, _writeLock, _logger); } private readonly string[] _saveColumns = @@ -356,6 +360,12 @@ namespace MediaBrowser.Server.Implementations.Persistence { lock (_disposeLock) { + if (_shrinkMemoryTimer != null) + { + _shrinkMemoryTimer.Dispose(); + _shrinkMemoryTimer = null; + } + if (_connection != null) { if (_connection.IsOpen()) diff --git a/MediaBrowser.Server.Implementations/Persistence/SqliteShrinkMemoryTimer.cs b/MediaBrowser.Server.Implementations/Persistence/SqliteShrinkMemoryTimer.cs index 01784d540..b5a0c10b1 100644 --- a/MediaBrowser.Server.Implementations/Persistence/SqliteShrinkMemoryTimer.cs +++ b/MediaBrowser.Server.Implementations/Persistence/SqliteShrinkMemoryTimer.cs @@ -19,7 +19,7 @@ namespace MediaBrowser.Server.Implementations.Persistence _writeLock = writeLock; _logger = logger; - _shrinkMemoryTimer = new Timer(TimerCallback, null, TimeSpan.FromMinutes(30), TimeSpan.FromMinutes(30)); + _shrinkMemoryTimer = new Timer(TimerCallback, null, TimeSpan.FromMinutes(30), TimeSpan.FromMinutes(10)); } private async void TimerCallback(object state) -- cgit v1.2.3