diff options
| author | Luke <luke.pulverenti@gmail.com> | 2017-08-06 19:01:30 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-08-06 19:01:30 -0400 |
| commit | e9bf2e413222af14ca791d989bd0470d5e282ae0 (patch) | |
| tree | 326030dc1915f3c4e00f4f10eab5c171b7e87ca4 /Emby.Server.Implementations | |
| parent | d8c2dd253277ba2ce7a5a7496b278db0e4e85106 (diff) | |
| parent | 6d78824c8e9fa9fe1e46944ca6901af724b8f7cd (diff) | |
Merge pull request #2796 from MediaBrowser/dev
Dev
Diffstat (limited to 'Emby.Server.Implementations')
5 files changed, 35 insertions, 158 deletions
diff --git a/Emby.Server.Implementations/Data/SqliteItemRepository.cs b/Emby.Server.Implementations/Data/SqliteItemRepository.cs index 3825389bf..44b2cd10b 100644 --- a/Emby.Server.Implementations/Data/SqliteItemRepository.cs +++ b/Emby.Server.Implementations/Data/SqliteItemRepository.cs @@ -228,7 +228,6 @@ namespace Emby.Server.Implementations.Data AddColumn(db, "TypedBaseItems", "TopParentId", "Text", existingColumnNames); AddColumn(db, "TypedBaseItems", "TrailerTypes", "Text", existingColumnNames); AddColumn(db, "TypedBaseItems", "CriticRating", "Float", existingColumnNames); - AddColumn(db, "TypedBaseItems", "InheritedTags", "Text", existingColumnNames); AddColumn(db, "TypedBaseItems", "CleanName", "Text", existingColumnNames); AddColumn(db, "TypedBaseItems", "PresentationUniqueKey", "Text", existingColumnNames); AddColumn(db, "TypedBaseItems", "OriginalTitle", "Text", existingColumnNames); @@ -442,7 +441,6 @@ namespace Emby.Server.Implementations.Data "SeriesId", "PresentationUniqueKey", "InheritedParentalRatingValue", - "InheritedTags", "ExternalSeriesId", "Tagline", "ProviderIds", @@ -552,7 +550,6 @@ namespace Emby.Server.Implementations.Data "TopParentId", "TrailerTypes", "CriticRating", - "InheritedTags", "CleanName", "PresentationUniqueKey", "OriginalTitle", @@ -633,7 +630,7 @@ namespace Emby.Server.Implementations.Data CheckDisposed(); - var tuples = new List<Tuple<BaseItem, List<Guid>, BaseItem, string>>(); + var tuples = new List<Tuple<BaseItem, List<Guid>, BaseItem, string, List<string>>>(); foreach (var item in items) { var ancestorIds = item.SupportsAncestors ? @@ -643,8 +640,9 @@ namespace Emby.Server.Implementations.Data var topParent = item.GetTopParent(); var userdataKey = item.GetUserDataKeys().FirstOrDefault(); + var inheritedTags = item.GetInheritedTags(); - tuples.Add(new Tuple<BaseItem, List<Guid>, BaseItem, string>(item, ancestorIds, topParent, userdataKey)); + tuples.Add(new Tuple<BaseItem, List<Guid>, BaseItem, string, List<string>>(item, ancestorIds, topParent, userdataKey, inheritedTags)); } using (WriteLock.Write()) @@ -654,12 +652,13 @@ namespace Emby.Server.Implementations.Data connection.RunInTransaction(db => { SaveItemsInTranscation(db, tuples); + }, TransactionMode); } } } - private void SaveItemsInTranscation(IDatabaseConnection db, List<Tuple<BaseItem, List<Guid>, BaseItem, string>> tuples) + private void SaveItemsInTranscation(IDatabaseConnection db, List<Tuple<BaseItem, List<Guid>, BaseItem, string, List<string>>> tuples) { var requiresReset = false; @@ -690,12 +689,14 @@ namespace Emby.Server.Implementations.Data SaveItem(item, topParent, userDataKey, saveItemStatement); //Logger.Debug(_saveItemCommand.CommandText); + var inheritedTags = tuple.Item5; + if (item.SupportsAncestors) { UpdateAncestors(item.Id, tuple.Item2, db, deleteAncestorsStatement, updateAncestorsStatement); } - UpdateItemValues(item.Id, GetItemValuesToSave(item), db); + UpdateItemValues(item.Id, GetItemValuesToSave(item, inheritedTags), db); requiresReset = true; } @@ -806,7 +807,7 @@ namespace Emby.Server.Implementations.Data saveItemStatement.TryBind("@RunTimeTicks", item.RunTimeTicks); saveItemStatement.TryBind("@HomePageUrl", item.HomePageUrl); - saveItemStatement.TryBind("@DisplayMediaType", item.DisplayMediaType); + saveItemStatement.TryBindNull("@DisplayMediaType"); saveItemStatement.TryBind("@DateCreated", item.DateCreated); saveItemStatement.TryBind("@DateModified", item.DateModified); @@ -900,16 +901,6 @@ namespace Emby.Server.Implementations.Data saveItemStatement.TryBind("@CriticRating", item.CriticRating); - var inheritedTags = item.InheritedTags; - if (inheritedTags.Count > 0) - { - saveItemStatement.TryBind("@InheritedTags", string.Join("|", inheritedTags.ToArray())); - } - else - { - saveItemStatement.TryBindNull("@InheritedTags"); - } - if (string.IsNullOrWhiteSpace(item.Name)) { saveItemStatement.TryBindNull("@CleanName"); @@ -1579,11 +1570,15 @@ namespace Emby.Server.Implementations.Data index++; } + var video = item as Video; if (HasField(query, ItemFields.DisplayMediaType)) { - if (!reader.IsDBNull(index)) + if (video != null) { - item.DisplayMediaType = reader.GetString(index); + if (!reader.IsDBNull(index)) + { + video.DisplayMediaType = reader.GetString(index); + } } index++; } @@ -1739,7 +1734,6 @@ namespace Emby.Server.Implementations.Data index++; } - var video = item as Video; if (video != null) { if (!reader.IsDBNull(index)) @@ -1842,15 +1836,6 @@ namespace Emby.Server.Implementations.Data index++; } - if (HasField(query, ItemFields.Tags)) - { - if (!reader.IsDBNull(index)) - { - item.InheritedTags = reader.GetString(index).Split('|').Where(i => !string.IsNullOrWhiteSpace(i)).ToList(); - } - index++; - } - if (HasField(query, ItemFields.ExternalSeriesId)) { if (!reader.IsDBNull(index)) @@ -2245,7 +2230,7 @@ namespace Emby.Server.Implementations.Data } if (field == ItemFields.Tags) { - return new[] { "Tags", "InheritedTags" }; + return new[] { "Tags" }; } return new[] { field.ToString() }; @@ -2258,8 +2243,8 @@ namespace Emby.Server.Implementations.Data switch (name) { case ItemFields.HomePageUrl: - case ItemFields.DisplayMediaType: case ItemFields.CustomRating: + case ItemFields.DisplayMediaType: case ItemFields.ProductionLocations: case ItemFields.Settings: case ItemFields.OriginalTitle: @@ -4555,26 +4540,12 @@ namespace Emby.Server.Implementations.Data whereClauses.Add(string.Format("(InheritedParentalRatingValue > 0 or UnratedType not in ({0}))", inClause)); } - var excludeTagIndex = 0; - foreach (var excludeTag in query.ExcludeTags) + if (query.ExcludeInheritedTags.Length > 0) { - whereClauses.Add("(Tags is null OR Tags not like @excludeTag" + excludeTagIndex + ")"); - if (statement != null) - { - statement.TryBind("@excludeTag" + excludeTagIndex, "%" + excludeTag + "%"); - } - excludeTagIndex++; - } + var tagValues = query.ExcludeInheritedTags.Select(i => "'" + GetCleanValue(i) + "'").ToArray(); + var tagValuesList = string.Join(",", tagValues); - excludeTagIndex = 0; - foreach (var excludeTag in query.ExcludeInheritedTags) - { - whereClauses.Add("(InheritedTags is null OR InheritedTags not like @excludeInheritedTag" + excludeTagIndex + ")"); - if (statement != null) - { - statement.TryBind("@excludeInheritedTag" + excludeTagIndex, "%" + excludeTag + "%"); - } - excludeTagIndex++; + whereClauses.Add("((select CleanValue from itemvalues where ItemId=Guid and Type=6 and cleanvalue in (" + tagValuesList + ")) is null)"); } return whereClauses; @@ -4724,7 +4695,7 @@ namespace Emby.Server.Implementations.Data { var newValues = new List<Tuple<Guid, string>>(); - var commandText = "select Guid,InheritedTags,(select group_concat(Tags, '|') from TypedBaseItems where (guid=outer.guid) OR (guid in (Select AncestorId from AncestorIds where ItemId=Outer.guid))) as NewInheritedTags from typedbaseitems as Outer where NewInheritedTags <> InheritedTags"; + var commandText = "select Guid,(select group_concat(Tags, '|') from TypedBaseItems where (guid=outer.guid) OR (guid in (Select AncestorId from AncestorIds where ItemId=Outer.guid))) as NewInheritedTags from typedbaseitems as Outer"; using (WriteLock.Write()) { @@ -5445,7 +5416,7 @@ namespace Emby.Server.Implementations.Data return counts; } - private List<Tuple<int, string>> GetItemValuesToSave(BaseItem item) + private List<Tuple<int, string>> GetItemValuesToSave(BaseItem item, List<string> inheritedTags) { var list = new List<Tuple<int, string>>(); @@ -5465,6 +5436,10 @@ namespace Emby.Server.Implementations.Data list.AddRange(item.Studios.Select(i => new Tuple<int, string>(3, i))); list.AddRange(item.Tags.Select(i => new Tuple<int, string>(4, i))); + // keywords was 5 + + list.AddRange(inheritedTags.Select(i => new Tuple<int, string>(6, i))); + return list; } diff --git a/Emby.Server.Implementations/Dto/DtoService.cs b/Emby.Server.Implementations/Dto/DtoService.cs index c50e5600a..80576742e 100644 --- a/Emby.Server.Implementations/Dto/DtoService.cs +++ b/Emby.Server.Implementations/Dto/DtoService.cs @@ -517,7 +517,7 @@ namespace Emby.Server.Implementations.Dto } } - if (!(item is LiveTvProgram) || fields.Contains(ItemFields.PlayAccess)) + if (/*!(item is LiveTvProgram) ||*/ fields.Contains(ItemFields.PlayAccess)) { dto.PlayAccess = item.GetPlayAccess(user); } @@ -864,11 +864,6 @@ namespace Emby.Server.Implementations.Dto dto.DateCreated = item.DateCreated; } - if (fields.Contains(ItemFields.DisplayMediaType)) - { - dto.DisplayMediaType = item.DisplayMediaType; - } - if (fields.Contains(ItemFields.Settings)) { dto.LockedFields = item.LockedFields; diff --git a/Emby.Server.Implementations/IO/FileRefresher.cs b/Emby.Server.Implementations/IO/FileRefresher.cs index d4914e734..b2554049d 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/LiveTv/LiveTvManager.cs b/Emby.Server.Implementations/LiveTv/LiveTvManager.cs index 48c74681f..9b832bd4a 100644 --- a/Emby.Server.Implementations/LiveTv/LiveTvManager.cs +++ b/Emby.Server.Implementations/LiveTv/LiveTvManager.cs @@ -2350,6 +2350,7 @@ namespace Emby.Server.Implementations.LiveTv var addCurrentProgram = options.AddCurrentProgram; var addMediaSources = options.Fields.Contains(ItemFields.MediaSources); + var addServiceName = options.Fields.Contains(ItemFields.ServiceName); foreach (var tuple in tuples) { @@ -2359,7 +2360,11 @@ namespace Emby.Server.Implementations.LiveTv dto.Number = channel.Number; dto.ChannelNumber = channel.Number; dto.ChannelType = channel.ChannelType; - dto.ServiceName = channel.ServiceName; + + if (addServiceName) + { + dto.ServiceName = channel.ServiceName; + } currentChannelsDict[dto.Id] = dto; diff --git a/Emby.Server.Implementations/MediaEncoder/EncodingManager.cs b/Emby.Server.Implementations/MediaEncoder/EncodingManager.cs index 181a49034..60379f5ec 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<string> playableStreamFileNames = null; if (video.VideoType == VideoType.BluRay || video.VideoType == VideoType.Dvd) { continue; } - if (playableStreamFileNames == null) - { - playableStreamFileNames = new List<string>(); - } - 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<string>()); _fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(path)); |
