From 27c490c15256951a4e2172566c7313f33e0f0af3 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sun, 6 Aug 2017 01:50:37 -0400 Subject: [PATCH 1/2] update file refresher --- .../IO/FileRefresher.cs | 92 ------------------- .../MediaEncoder/EncodingManager.cs | 8 +- .../MediaInfo/VideoImageProvider.cs | 2 +- 3 files changed, 2 insertions(+), 100 deletions(-) diff --git a/Emby.Server.Implementations/IO/FileRefresher.cs b/Emby.Server.Implementations/IO/FileRefresher.cs index d4914e734e..b2554049d1 100644 --- a/Emby.Server.Implementations/IO/FileRefresher.cs +++ b/Emby.Server.Implementations/IO/FileRefresher.cs @@ -130,14 +130,6 @@ namespace Emby.Server.Implementations.IO paths = _affectedPaths.ToList(); } - // Extend the timer as long as any of the paths are still being written to. - if (paths.Any(IsFileLocked)) - { - Logger.Info("Timer extended."); - RestartTimer(); - return; - } - Logger.Debug("Timer stopped."); DisposeTimer(); @@ -229,90 +221,6 @@ namespace Emby.Server.Implementations.IO return item; } - private bool IsFileLocked(string path) - { - if (_environmentInfo.OperatingSystem != MediaBrowser.Model.System.OperatingSystem.Windows) - { - // Causing lockups on linux - return false; - } - - // Only try to open video files - if (!_libraryManager.IsVideoFile(path)) - { - return false; - } - - try - { - var data = _fileSystem.GetFileSystemInfo(path); - - if (!data.Exists - || data.IsDirectory - - // Opening a writable stream will fail with readonly files - || data.IsReadOnly) - { - return false; - } - } - catch (IOException) - { - return false; - } - catch (Exception ex) - { - Logger.ErrorException("Error getting file system info for: {0}", ex, path); - return false; - } - - // In order to determine if the file is being written to, we have to request write access - // But if the server only has readonly access, this is going to cause this entire algorithm to fail - // So we'll take a best guess about our access level - //var requestedFileAccess = ConfigurationManager.Configuration.SaveLocalMeta - // ? FileAccessMode.ReadWrite - // : FileAccessMode.Read; - - var requestedFileAccess = FileAccessMode.Read; - try - { - using (_fileSystem.GetFileStream(path, FileOpenMode.Open, requestedFileAccess, FileShareMode.ReadWrite)) - { - //file is not locked - return false; - } - } - catch (DirectoryNotFoundException) - { - // File may have been deleted - return false; - } - catch (FileNotFoundException) - { - // File may have been deleted - return false; - } - catch (UnauthorizedAccessException) - { - Logger.Debug("No write permission for: {0}.", path); - return false; - } - catch (IOException) - { - //the file is unavailable because it is: - //still being written to - //or being processed by another thread - //or does not exist (has already been processed) - Logger.Debug("{0} is locked.", path); - return true; - } - catch (Exception ex) - { - Logger.ErrorException("Error determining if file is locked: {0}", ex, path); - return false; - } - } - private void DisposeTimer() { lock (_timerLock) diff --git a/Emby.Server.Implementations/MediaEncoder/EncodingManager.cs b/Emby.Server.Implementations/MediaEncoder/EncodingManager.cs index 181a49034e..60379f5ec6 100644 --- a/Emby.Server.Implementations/MediaEncoder/EncodingManager.cs +++ b/Emby.Server.Implementations/MediaEncoder/EncodingManager.cs @@ -122,17 +122,11 @@ namespace Emby.Server.Implementations.MediaEncoder continue; } - List playableStreamFileNames = null; if (video.VideoType == VideoType.BluRay || video.VideoType == VideoType.Dvd) { continue; } - if (playableStreamFileNames == null) - { - playableStreamFileNames = new List(); - } - try { // Add some time for the first chapter to make sure we don't end up with a black image @@ -140,7 +134,7 @@ namespace Emby.Server.Implementations.MediaEncoder var protocol = MediaProtocol.File; - var inputPath = MediaEncoderHelpers.GetInputArgument(_fileSystem, video.Path, protocol, null, playableStreamFileNames); + var inputPath = MediaEncoderHelpers.GetInputArgument(_fileSystem, video.Path, protocol, null, new List()); _fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(path)); diff --git a/MediaBrowser.Providers/MediaInfo/VideoImageProvider.cs b/MediaBrowser.Providers/MediaInfo/VideoImageProvider.cs index cdf5772c23..0d0b680bdb 100644 --- a/MediaBrowser.Providers/MediaInfo/VideoImageProvider.cs +++ b/MediaBrowser.Providers/MediaInfo/VideoImageProvider.cs @@ -45,7 +45,7 @@ namespace MediaBrowser.Providers.MediaInfo } // No support for this - if (video.VideoType == VideoType.Iso) + if (video.VideoType == VideoType.Iso || video.VideoType == VideoType.Dvd || video.VideoType == VideoType.BluRay) { return Task.FromResult(new DynamicImageResponse { HasImage = false }); } From 6d78824c8e9fa9fe1e46944ca6901af724b8f7cd Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sun, 6 Aug 2017 19:01:00 -0400 Subject: [PATCH 2/2] update components --- Emby.Server.Core/ApplicationHost.cs | 72 ++++++++--------- .../Data/SqliteItemRepository.cs | 79 +++++++------------ Emby.Server.Implementations/Dto/DtoService.cs | 7 +- .../LiveTv/LiveTvManager.cs | 7 +- MediaBrowser.Api/Playback/MediaInfoService.cs | 13 ++- MediaBrowser.Api/SearchService.cs | 1 - .../Collections/ManualCollectionsFolder.cs | 1 - .../Entities/Audio/Audio.cs | 2 + MediaBrowser.Controller/Entities/BaseItem.cs | 17 ++-- .../Entities/IHasImages.cs | 8 +- .../Entities/IHasMetadata.cs | 1 - .../Entities/MusicVideo.cs | 1 + MediaBrowser.Controller/Entities/Video.cs | 6 ++ .../Parsers/BaseItemXmlParser.cs | 12 --- .../Savers/BaseXmlSaver.cs | 6 -- MediaBrowser.Model/Dto/BaseItemDto.cs | 6 -- MediaBrowser.Model/Search/SearchHint.cs | 6 -- MediaBrowser.Model/Users/UserPolicy.cs | 2 + .../Manager/MetadataService.cs | 7 -- .../Manager/ProviderUtils.cs | 13 ++- .../Parsers/BaseNfoParser.cs | 15 ---- .../Savers/BaseNfoSaver.cs | 6 -- Nuget/MediaBrowser.Common.nuspec | 2 +- Nuget/MediaBrowser.Server.Core.nuspec | 4 +- SharedVersion.cs | 2 +- 25 files changed, 111 insertions(+), 185 deletions(-) diff --git a/Emby.Server.Core/ApplicationHost.cs b/Emby.Server.Core/ApplicationHost.cs index 8a239a2286..68cb2a4e32 100644 --- a/Emby.Server.Core/ApplicationHost.cs +++ b/Emby.Server.Core/ApplicationHost.cs @@ -410,7 +410,7 @@ namespace Emby.Server.Core { Logger.ErrorException("Error in {0}", ex, name); } - Logger.Info("Entry point completed: {0}. Duration: {1} seconds", name, (DateTime.UtcNow - now).TotalSeconds.ToString(CultureInfo.InvariantCulture)); + Logger.Info("Entry point completed: {0}. Duration: {1} seconds", name, (DateTime.UtcNow - now).TotalSeconds.ToString(CultureInfo.InvariantCulture), "ImageInfos"); } Logger.Info("All entry points have started"); @@ -431,41 +431,41 @@ namespace Emby.Server.Core var result = new JsonSerializer(FileSystemManager, LogManager.GetLogger("JsonSerializer")); - ServiceStack.Text.JsConfig.ExcludePropertyNames = new[] { "ProviderIds", "ImageInfos", "ProductionLocations", "ThemeSongIds", "ThemeVideoIds", "TotalBitrate", "Taglines", "ExtraType" }; - ServiceStack.Text.JsConfig.ExcludePropertyNames = new[] { "ProviderIds", "ImageInfos", "ProductionLocations", "ThemeSongIds", "ThemeVideoIds", "TotalBitrate", "Taglines", "ExtraType" }; - ServiceStack.Text.JsConfig.ExcludePropertyNames = new[] { "ProviderIds", "ImageInfos", "ProductionLocations", "ThemeSongIds", "ThemeVideoIds", "TotalBitrate", "Taglines", "ExtraType" }; - ServiceStack.Text.JsConfig.ExcludePropertyNames = new[] { "Artists", "AlbumArtists", "ChannelMediaSources", "ProviderIds", "ImageInfos", "ProductionLocations", "ThemeSongIds", "ThemeVideoIds", "TotalBitrate", "Taglines", "ExtraType" }; - ServiceStack.Text.JsConfig.ExcludePropertyNames = new[] { "ProviderIds", "ImageInfos", "ProductionLocations", "ThemeSongIds", "ThemeVideoIds", "TotalBitrate", "Taglines", "ExtraType" }; - ServiceStack.Text.JsConfig