2
0
Эх сурвалжийг харах

reduce rescanning due to IsOffline

Luke Pulverenti 8 жил өмнө
parent
commit
e4851e1b25

+ 6 - 3
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.Playback
                 return Task.FromResult(true);
             }
 
-            if (!string.Equals(MediaEncoder.EncoderLocationType, "Default", StringComparison.OrdinalIgnoreCase))
+            if (!MediaEncoder.IsDefaultEncoderPath)
             {
                 return Task.FromResult(true);
             }

+ 18 - 4
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))
                 {

+ 2 - 13
MediaBrowser.Controller/Entities/Folder.cs

@@ -375,7 +375,7 @@ namespace MediaBrowser.Controller.Entities
 
                     if (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.Entities
 
                         else 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.Entities
             progress.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();

+ 1 - 0
MediaBrowser.Controller/MediaEncoding/IMediaEncoder.cs

@@ -134,5 +134,6 @@ namespace MediaBrowser.Controller.MediaEncoding
 
         Task UpdateEncoderPath(string path, string pathType);
         bool SupportsEncoder(string encoder);
+        bool IsDefaultEncoderPath { get; }
     }
 }

+ 1 - 1
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);
                 }

+ 8 - 8
MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs

@@ -123,20 +123,20 @@ namespace MediaBrowser.MediaEncoding.Encoder
                     return "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)

+ 0 - 1
MediaBrowser.Model/Configuration/UserConfiguration.cs

@@ -48,7 +48,6 @@ namespace MediaBrowser.Model.Configuration
         public 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.

+ 6 - 3
MediaBrowser.Providers/MediaInfo/AudioImageProvider.cs

@@ -167,10 +167,13 @@ namespace MediaBrowser.Providers.MediaInfo
 
         public 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;

+ 1 - 1
MediaBrowser.Providers/MediaInfo/FFProbeProvider.cs

@@ -171,7 +171,7 @@ namespace MediaBrowser.Providers.MediaInfo
 
         public 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)

+ 1 - 1
MediaBrowser.Providers/MediaInfo/VideoImageProvider.cs

@@ -194,7 +194,7 @@ namespace MediaBrowser.Providers.MediaInfo
 
         public 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)

+ 6 - 3
MediaBrowser.Providers/Photos/PhotoProvider.cs

@@ -154,10 +154,13 @@ namespace MediaBrowser.Providers.Photos
 
         public 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;

+ 1 - 2
MediaBrowser.Server.Implementations/Persistence/CleanDatabaseScheduledTask.cs

@@ -313,8 +313,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
 
                     if (Folder.IsPathOffline(path))
                     {
-                        libraryItem.IsOffline = true;
-                        await libraryItem.UpdateToRepository(ItemUpdateType.None, cancellationToken).ConfigureAwait(false);
+                        await libraryItem.UpdateIsOffline(true).ConfigureAwait(false);
                         continue;
                     }
 

+ 0 - 3
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;

+ 0 - 1
MediaBrowser.Server.Startup.Common/ApplicationHost.cs

@@ -386,7 +386,6 @@ namespace MediaBrowser.Server.Startup.Common
                 new 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)
             };

+ 0 - 1
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" />

+ 0 - 40
MediaBrowser.Server.Startup.Common/Migrations/FolderViewSettingMigration.cs

@@ -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();
-            }
-
-        }
-    }
-}