The Free Software Media System - Server Backend & API
reduce rescanning due to IsOffline
Luke Pulverentie4851e1b25e7
diff --git a/MediaBrowser.Api/Playback/BaseStreamingService.cs b/MediaBrowser.Api/Playback/BaseStreamingService.csindex 4c8b918c6a..6f4b6323d6 100644--- a/MediaBrowser.Api/Playback/BaseStreamingService.cs+++ b/MediaBrowser.Api/Playback/BaseStreamingService.cs@@ -298,7 +298,8 @@ namespace MediaBrowser.Api.Playback// Since transcoding of folder rips is expiremental anyway, it's not worth adding additional variables such as this.if (state.VideoType == VideoType.VideoFile){- var hwType = ApiEntryPoint.Instance.GetEncodingOptions().HardwareAccelerationType;+ var encodingOptions = ApiEntryPoint.Instance.GetEncodingOptions();+ var hwType = encodingOptions.HardwareAccelerationType;if (string.Equals(hwType, "qsv", StringComparison.OrdinalIgnoreCase) ||string.Equals(hwType, "h264_qsv", StringComparison.OrdinalIgnoreCase))@@ -314,7 +315,7 @@ namespace MediaBrowser.Api.Playback{return GetAvailableEncoder("h264_omx", defaultEncoder);}- if (string.Equals(hwType, "vaapi", StringComparison.OrdinalIgnoreCase))+ if (string.Equals(hwType, "vaapi", StringComparison.OrdinalIgnoreCase) && !string.IsNullOrWhiteSpace(encodingOptions.VaapiDevice)){return GetAvailableEncoder("h264_vaapi", defaultEncoder);}@@ -988,6 +989,8 @@ namespace MediaBrowser.Api.Playback}}+ arg += string.Format(" -ss {0}", MediaEncoder.GetTimeParameter(TimeSpan.FromSeconds(1).Ticks));+return arg.Trim();}@@ -2289,7 +2292,7 @@ namespace MediaBrowser.Api.Playbackreturn Task.FromResult(true);}- if (!string.Equals(MediaEncoder.EncoderLocationType, "Default", StringComparison.OrdinalIgnoreCase))+ if (!MediaEncoder.IsDefaultEncoderPath){return Task.FromResult(true);}diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.csindex cbbb9a89a3..984374a499 100644--- a/MediaBrowser.Controller/Entities/BaseItem.cs+++ b/MediaBrowser.Controller/Entities/BaseItem.cs@@ -281,6 +281,20 @@ namespace MediaBrowser.Controller.Entities}}+ public Task UpdateIsOffline(bool newValue)+ {+ var item = this;++ if (item.IsOffline != newValue)+ {+ item.IsOffline = newValue;+ // this is creating too many repeated db updates+ //return item.UpdateToRepository(ItemUpdateType.None, CancellationToken.None);+ }++ return Task.FromResult(true);+ }+/// <summary>/// Gets or sets the type of the location./// </summary>@@ -290,10 +304,10 @@ namespace MediaBrowser.Controller.Entities{get{- if (IsOffline)- {- return LocationType.Offline;- }+ //if (IsOffline)+ //{+ // return LocationType.Offline;+ //}if (string.IsNullOrWhiteSpace(Path)){diff --git a/MediaBrowser.Controller/Entities/Folder.cs b/MediaBrowser.Controller/Entities/Folder.csindex b5c76c0ebc..bea648a3d3 100644--- a/MediaBrowser.Controller/Entities/Folder.cs+++ b/MediaBrowser.Controller/Entities/Folder.cs@@ -375,7 +375,7 @@ namespace MediaBrowser.Controller.Entitiesif (currentChildren.TryGetValue(child.Id, out currentChild) && IsValidFromResolver(currentChild, child)){- await UpdateIsOffline(currentChild, false).ConfigureAwait(false);+ await currentChild.UpdateIsOffline(false).ConfigureAwait(false);validChildren.Add(currentChild);continue;@@ -404,7 +404,7 @@ namespace MediaBrowser.Controller.Entitieselse if (!string.IsNullOrEmpty(item.Path) && IsPathOffline(item.Path)){- await UpdateIsOffline(item, true).ConfigureAwait(false);+ await item.UpdateIsOffline(true).ConfigureAwait(false);}else{@@ -461,17 +461,6 @@ namespace MediaBrowser.Controller.Entitiesprogress.Report(100);}- private Task UpdateIsOffline(BaseItem item, bool newValue)- {- if (item.IsOffline != newValue)- {- item.IsOffline = newValue;- return item.UpdateToRepository(ItemUpdateType.None, CancellationToken.None);- }-- return Task.FromResult(true);- }-private async Task RefreshMetadataRecursive(MetadataRefreshOptions refreshOptions, bool recursive, IProgress<double> progress, CancellationToken cancellationToken){var children = ActualChildren.ToList();diff --git a/MediaBrowser.Controller/MediaEncoding/IMediaEncoder.cs b/MediaBrowser.Controller/MediaEncoding/IMediaEncoder.csindex 1fef8bead7..7fdbf020ce 100644--- a/MediaBrowser.Controller/MediaEncoding/IMediaEncoder.cs+++ b/MediaBrowser.Controller/MediaEncoding/IMediaEncoder.cs@@ -134,5 +134,6 @@ namespace MediaBrowser.Controller.MediaEncodingTask UpdateEncoderPath(string path, string pathType);bool SupportsEncoder(string encoder);+ bool IsDefaultEncoderPath { get; }}}diff --git a/MediaBrowser.MediaEncoding/Encoder/EncodingJobFactory.cs b/MediaBrowser.MediaEncoding/Encoder/EncodingJobFactory.csindex b5e97f09a1..c725326691 100644--- a/MediaBrowser.MediaEncoding/Encoder/EncodingJobFactory.cs+++ b/MediaBrowser.MediaEncoding/Encoder/EncodingJobFactory.cs@@ -586,7 +586,7 @@ namespace MediaBrowser.MediaEncoding.Encoder{return GetAvailableEncoder(mediaEncoder, "h264_omx", defaultEncoder);}- if (string.Equals(hwType, "vaapi", StringComparison.OrdinalIgnoreCase))+ if (string.Equals(hwType, "vaapi", StringComparison.OrdinalIgnoreCase) && !string.IsNullOrWhiteSpace(options.VaapiDevice)){return GetAvailableEncoder(mediaEncoder, "h264_vaapi", defaultEncoder);}diff --git a/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs b/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.csindex f488be11a7..ad84ffee82 100644--- a/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs+++ b/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs@@ -123,20 +123,20 @@ namespace MediaBrowser.MediaEncoding.Encoderreturn "System";}- if (IsDefaultPath(FFMpegPath))- {- return "Default";- }-return "Custom";}}- private bool IsDefaultPath(string path)+ public bool IsDefaultEncoderPath{- var parentPath = Path.Combine(ConfigurationManager.ApplicationPaths.ProgramDataPath, "ffmpeg", "20160410");+ get+ {+ var path = FFMpegPath;++ var parentPath = Path.Combine(ConfigurationManager.ApplicationPaths.ProgramDataPath, "ffmpeg", "20160410");- return FileSystem.ContainsSubPath(parentPath, path);+ return FileSystem.ContainsSubPath(parentPath, path);+ }}private bool IsSystemInstalledPath(string path)diff --git a/MediaBrowser.Model/Configuration/UserConfiguration.cs b/MediaBrowser.Model/Configuration/UserConfiguration.csindex 69dc23b21c..b081e29737 100644--- a/MediaBrowser.Model/Configuration/UserConfiguration.cs+++ b/MediaBrowser.Model/Configuration/UserConfiguration.cs@@ -48,7 +48,6 @@ namespace MediaBrowser.Model.Configurationpublic bool RememberAudioSelections { get; set; }public bool RememberSubtitleSelections { get; set; }public bool EnableNextEpisodeAutoPlay { get; set; }- public bool DisplayFoldersView { get; set; }/// <summary>/// Initializes a new instance of the <see cref="UserConfiguration" /> class.diff --git a/MediaBrowser.Providers/MediaInfo/AudioImageProvider.cs b/MediaBrowser.Providers/MediaInfo/AudioImageProvider.csindex 6c79189887..027341ee6a 100644--- a/MediaBrowser.Providers/MediaInfo/AudioImageProvider.cs+++ b/MediaBrowser.Providers/MediaInfo/AudioImageProvider.cs@@ -167,10 +167,13 @@ namespace MediaBrowser.Providers.MediaInfopublic bool HasChanged(IHasMetadata item, IDirectoryService directoryService){- var file = directoryService.GetFile(item.Path);- if (file != null && file.LastWriteTimeUtc != item.DateModified)+ if (item.EnableRefreshOnDateModifiedChange && !string.IsNullOrWhiteSpace(item.Path) && item.LocationType == LocationType.FileSystem){- return true;+ var file = directoryService.GetFile(item.Path);+ if (file != null && file.LastWriteTimeUtc != item.DateModified)+ {+ return true;+ }}return false;diff --git a/MediaBrowser.Providers/MediaInfo/FFProbeProvider.cs b/MediaBrowser.Providers/MediaInfo/FFProbeProvider.csindex 0df8b6c4b7..d255110fb7 100644--- a/MediaBrowser.Providers/MediaInfo/FFProbeProvider.cs+++ b/MediaBrowser.Providers/MediaInfo/FFProbeProvider.cs@@ -171,7 +171,7 @@ namespace MediaBrowser.Providers.MediaInfopublic bool HasChanged(IHasMetadata item, IDirectoryService directoryService){- if (item.EnableRefreshOnDateModifiedChange && !string.IsNullOrWhiteSpace(item.Path))+ if (item.EnableRefreshOnDateModifiedChange && !string.IsNullOrWhiteSpace(item.Path) && item.LocationType == LocationType.FileSystem){var file = directoryService.GetFile(item.Path);if (file != null && file.LastWriteTimeUtc != item.DateModified)diff --git a/MediaBrowser.Providers/MediaInfo/VideoImageProvider.cs b/MediaBrowser.Providers/MediaInfo/VideoImageProvider.csindex 280e92beb9..2ad02da2ef 100644--- a/MediaBrowser.Providers/MediaInfo/VideoImageProvider.cs+++ b/MediaBrowser.Providers/MediaInfo/VideoImageProvider.cs@@ -194,7 +194,7 @@ namespace MediaBrowser.Providers.MediaInfopublic bool HasChanged(IHasMetadata item, IDirectoryService directoryService){- if (item.EnableRefreshOnDateModifiedChange)+ if (item.EnableRefreshOnDateModifiedChange && !string.IsNullOrWhiteSpace(item.Path) && item.LocationType == LocationType.FileSystem){var file = directoryService.GetFile(item.Path);if (file != null && file.LastWriteTimeUtc != item.DateModified)diff --git a/MediaBrowser.Providers/Photos/PhotoProvider.cs b/MediaBrowser.Providers/Photos/PhotoProvider.csindex 619b726368..c48c3d09be 100644--- a/MediaBrowser.Providers/Photos/PhotoProvider.cs+++ b/MediaBrowser.Providers/Photos/PhotoProvider.cs@@ -154,10 +154,13 @@ namespace MediaBrowser.Providers.Photospublic bool HasChanged(IHasMetadata item, IDirectoryService directoryService){- var file = directoryService.GetFile(item.Path);- if (file != null && file.LastWriteTimeUtc != item.DateModified)+ if (item.EnableRefreshOnDateModifiedChange && !string.IsNullOrWhiteSpace(item.Path) && item.LocationType == LocationType.FileSystem){- return true;+ var file = directoryService.GetFile(item.Path);+ if (file != null && file.LastWriteTimeUtc != item.DateModified)+ {+ return true;+ }}return false;diff --git a/MediaBrowser.Server.Implementations/Persistence/CleanDatabaseScheduledTask.cs b/MediaBrowser.Server.Implementations/Persistence/CleanDatabaseScheduledTask.csindex bf2afb5ace..c1394ee1c3 100644--- a/MediaBrowser.Server.Implementations/Persistence/CleanDatabaseScheduledTask.cs+++ b/MediaBrowser.Server.Implementations/Persistence/CleanDatabaseScheduledTask.cs@@ -313,8 +313,7 @@ namespace MediaBrowser.Server.Implementations.Persistenceif (Folder.IsPathOffline(path)){- libraryItem.IsOffline = true;- await libraryItem.UpdateToRepository(ItemUpdateType.None, cancellationToken).ConfigureAwait(false);+ await libraryItem.UpdateIsOffline(true).ConfigureAwait(false);continue;}diff --git a/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs b/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.csindex b9befb531e..5c94d589dc 100644--- a/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs+++ b/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs@@ -211,7 +211,6 @@ namespace MediaBrowser.Server.Implementations.Persistence_connection.AddColumn(Logger, "TypedBaseItems", "ProductionYear", "INT");_connection.AddColumn(Logger, "TypedBaseItems", "ParentId", "GUID");_connection.AddColumn(Logger, "TypedBaseItems", "Genres", "Text");- _connection.AddColumn(Logger, "TypedBaseItems", "ParentalRatingValue", "INT");_connection.AddColumn(Logger, "TypedBaseItems", "SchemaVersion", "INT");_connection.AddColumn(Logger, "TypedBaseItems", "SortName", "Text");_connection.AddColumn(Logger, "TypedBaseItems", "RunTimeTicks", "BIGINT");@@ -488,7 +487,6 @@ namespace MediaBrowser.Server.Implementations.Persistence"ProductionYear","ParentId","Genres",- "ParentalRatingValue","InheritedParentalRatingValue","SchemaVersion","SortName",@@ -795,7 +793,6 @@ namespace MediaBrowser.Server.Implementations.Persistence}_saveItemCommand.GetParameter(index++).Value = string.Join("|", item.Genres.ToArray());- _saveItemCommand.GetParameter(index++).Value = item.GetParentalRatingValue() ?? 0;_saveItemCommand.GetParameter(index++).Value = item.GetInheritedParentalRatingValue() ?? 0;_saveItemCommand.GetParameter(index++).Value = LatestSchemaVersion;diff --git a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs b/MediaBrowser.Server.Startup.Common/ApplicationHost.csindex 8516e54ee9..75f2d24270 100644--- a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs+++ b/MediaBrowser.Server.Startup.Common/ApplicationHost.cs@@ -386,7 +386,6 @@ namespace MediaBrowser.Server.Startup.Commonnew MovieDbEpisodeProviderMigration(ServerConfigurationManager),new DbMigration(ServerConfigurationManager, TaskManager),new UpdateLevelMigration(ServerConfigurationManager, this, HttpClient, JsonSerializer, _releaseAssetFilename),- new FolderViewSettingMigration(ServerConfigurationManager, UserManager),new CollectionGroupingMigration(ServerConfigurationManager, UserManager),new CollectionsViewMigration(ServerConfigurationManager, UserManager)};diff --git a/MediaBrowser.Server.Startup.Common/MediaBrowser.Server.Startup.Common.csproj b/MediaBrowser.Server.Startup.Common/MediaBrowser.Server.Startup.Common.csprojindex 979a3a3577..bbef5caeae 100644--- a/MediaBrowser.Server.Startup.Common/MediaBrowser.Server.Startup.Common.csproj+++ b/MediaBrowser.Server.Startup.Common/MediaBrowser.Server.Startup.Common.csproj@@ -72,7 +72,6 @@<Compile Include="MbLinkShortcutHandler.cs" /><Compile Include="Migrations\CollectionGroupingMigration.cs" /><Compile Include="Migrations\CollectionsViewMigration.cs" />- <Compile Include="Migrations\FolderViewSettingMigration.cs" /><Compile Include="Migrations\IVersionMigration.cs" /><Compile Include="Migrations\DbMigration.cs" /><Compile Include="Migrations\MovieDbEpisodeProviderMigration.cs" />diff --git a/MediaBrowser.Server.Startup.Common/Migrations/FolderViewSettingMigration.cs b/MediaBrowser.Server.Startup.Common/Migrations/FolderViewSettingMigration.csdeleted file mode 100644index 12054864b3..0000000000--- a/MediaBrowser.Server.Startup.Common/Migrations/FolderViewSettingMigration.cs+++ /dev/null@@ -1,40 +0,0 @@-using System.Linq;-using MediaBrowser.Controller.Configuration;-using MediaBrowser.Controller.Library;--namespace MediaBrowser.Server.Startup.Common.Migrations-{- public class FolderViewSettingMigration : IVersionMigration- {- private readonly IServerConfigurationManager _config;- private readonly IUserManager _userManager;-- public FolderViewSettingMigration(IServerConfigurationManager config, IUserManager userManager)- {- _config = config;- _userManager = userManager;- }-- public void Run()- {- var migrationKey = this.GetType().Name;- var migrationKeyList = _config.Configuration.Migrations.ToList();-- if (!migrationKeyList.Contains(migrationKey))- {- if (_config.Configuration.IsStartupWizardCompleted)- {- if (_userManager.Users.Any(i => i.Configuration.DisplayFoldersView))- {- _config.Configuration.EnableFolderView = true;- }- }-- migrationKeyList.Add(migrationKey);- _config.Configuration.Migrations = migrationKeyList.ToArray();- _config.SaveConfiguration();- }-- }- }-}