Luke Pulverenti 7 anos atrás
pai
commit
a46840534f

+ 0 - 4
Emby.Common.Implementations/Net/UdpSocket.cs

@@ -37,8 +37,6 @@ namespace Emby.Common.Implementations.Net
         private TaskCompletionSource<SocketReceiveResult> _currentReceiveTaskCompletionSource;
         private TaskCompletionSource<SocketReceiveResult> _currentReceiveTaskCompletionSource;
         private TaskCompletionSource<int> _currentSendTaskCompletionSource;
         private TaskCompletionSource<int> _currentSendTaskCompletionSource;
 
 
-        private readonly SemaphoreSlim _sendLock = new SemaphoreSlim(1, 1);
-
         public UdpSocket(Socket socket, int localPort, IPAddress ip)
         public UdpSocket(Socket socket, int localPort, IPAddress ip)
         {
         {
             if (socket == null) throw new ArgumentNullException("socket");
             if (socket == null) throw new ArgumentNullException("socket");
@@ -234,8 +232,6 @@ namespace Emby.Common.Implementations.Net
                 if (socket != null)
                 if (socket != null)
                     socket.Dispose();
                     socket.Dispose();
 
 
-                _sendLock.Dispose();
-
                 var tcs = _currentReceiveTaskCompletionSource;
                 var tcs = _currentReceiveTaskCompletionSource;
                 if (tcs != null)
                 if (tcs != null)
                 {
                 {

+ 12 - 0
Emby.Drawing/ImageProcessor.cs

@@ -171,6 +171,13 @@ namespace Emby.Drawing
             return _imageEncoder.SupportedOutputFormats;
             return _imageEncoder.SupportedOutputFormats;
         }
         }
 
 
+        private static readonly string[] TransparentImageTypes = new string[] { ".png", ".webp" };
+        private bool SupportsTransparency(string path)
+        {
+            return TransparentImageTypes.Contains(Path.GetExtension(path) ?? string.Empty);
+            ;
+        }
+
         public async Task<Tuple<string, string, DateTime>> ProcessImage(ImageProcessingOptions options)
         public async Task<Tuple<string, string, DateTime>> ProcessImage(ImageProcessingOptions options)
         {
         {
             if (options == null)
             if (options == null)
@@ -260,6 +267,11 @@ namespace Emby.Drawing
                         item = _libraryManager().GetItemById(options.ItemId);
                         item = _libraryManager().GetItemById(options.ItemId);
                     }
                     }
 
 
+                    if (options.CropWhiteSpace && !SupportsTransparency(originalImagePath))
+                    {
+                        options.CropWhiteSpace = false;
+                    }
+
                     var resultPath = _imageEncoder.EncodeImage(originalImagePath, dateModified, tmpPath, autoOrient, orientation, quality, options, outputFormat);
                     var resultPath = _imageEncoder.EncodeImage(originalImagePath, dateModified, tmpPath, autoOrient, orientation, quality, options, outputFormat);
 
 
                     if (string.Equals(resultPath, originalImagePath, StringComparison.OrdinalIgnoreCase))
                     if (string.Equals(resultPath, originalImagePath, StringComparison.OrdinalIgnoreCase))

+ 94 - 23
Emby.Server.Implementations/Data/SqliteItemRepository.cs

@@ -233,7 +233,6 @@ namespace Emby.Server.Implementations.Data
                     AddColumn(db, "TypedBaseItems", "InheritedParentalRatingValue", "INT", existingColumnNames);
                     AddColumn(db, "TypedBaseItems", "InheritedParentalRatingValue", "INT", existingColumnNames);
                     AddColumn(db, "TypedBaseItems", "UnratedType", "Text", existingColumnNames);
                     AddColumn(db, "TypedBaseItems", "UnratedType", "Text", existingColumnNames);
                     AddColumn(db, "TypedBaseItems", "TopParentId", "Text", existingColumnNames);
                     AddColumn(db, "TypedBaseItems", "TopParentId", "Text", existingColumnNames);
-                    AddColumn(db, "TypedBaseItems", "IsItemByName", "BIT", existingColumnNames);
                     AddColumn(db, "TypedBaseItems", "TrailerTypes", "Text", existingColumnNames);
                     AddColumn(db, "TypedBaseItems", "TrailerTypes", "Text", existingColumnNames);
                     AddColumn(db, "TypedBaseItems", "CriticRating", "Float", existingColumnNames);
                     AddColumn(db, "TypedBaseItems", "CriticRating", "Float", existingColumnNames);
                     AddColumn(db, "TypedBaseItems", "InheritedTags", "Text", existingColumnNames);
                     AddColumn(db, "TypedBaseItems", "InheritedTags", "Text", existingColumnNames);
@@ -558,7 +557,6 @@ namespace Emby.Server.Implementations.Data
                 "IsFolder",
                 "IsFolder",
                 "UnratedType",
                 "UnratedType",
                 "TopParentId",
                 "TopParentId",
-                "IsItemByName",
                 "TrailerTypes",
                 "TrailerTypes",
                 "CriticRating",
                 "CriticRating",
                 "InheritedTags",
                 "InheritedTags",
@@ -897,15 +895,6 @@ namespace Emby.Server.Implementations.Data
                 saveItemStatement.TryBindNull("@TopParentId");
                 saveItemStatement.TryBindNull("@TopParentId");
             }
             }
 
 
-            var isByName = false;
-            var byName = item as IItemByName;
-            if (byName != null)
-            {
-                var dualAccess = item as IHasDualAccess;
-                isByName = dualAccess == null || dualAccess.IsAccessedByName;
-            }
-            saveItemStatement.TryBind("@IsItemByName", isByName);
-
             var trailer = item as Trailer;
             var trailer = item as Trailer;
             if (trailer != null && trailer.TrailerTypes.Count > 0)
             if (trailer != null && trailer.TrailerTypes.Count > 0)
             {
             {
@@ -1656,7 +1645,11 @@ namespace Emby.Server.Implementations.Data
 
 
             if (!reader.IsDBNull(index))
             if (!reader.IsDBNull(index))
             {
             {
-                item.Audio = (ProgramAudio)Enum.Parse(typeof(ProgramAudio), reader.GetString(index), true);
+                ProgramAudio audio;
+                if (Enum.TryParse(reader.GetString(index), true, out audio))
+                {
+                    item.Audio = audio;
+                }
             }
             }
             index++;
             index++;
 
 
@@ -1687,7 +1680,17 @@ namespace Emby.Server.Implementations.Data
             {
             {
                 if (!reader.IsDBNull(index))
                 if (!reader.IsDBNull(index))
                 {
                 {
-                    item.LockedFields = reader.GetString(index).Split('|').Where(i => !string.IsNullOrWhiteSpace(i)).Select(i => (MetadataFields)Enum.Parse(typeof(MetadataFields), i, true)).ToList();
+                    item.LockedFields = reader.GetString(index).Split('|').Where(i => !string.IsNullOrWhiteSpace(i)).Select(
+                        i =>
+                        {
+                            MetadataFields parsedValue;
+
+                            if (Enum.TryParse(i, true, out parsedValue))
+                            {
+                                return parsedValue;
+                            }
+                            return (MetadataFields?)null;
+                        }).Where(i => i.HasValue).Select(i => i.Value).ToList();
                 }
                 }
                 index++;
                 index++;
             }
             }
@@ -1717,7 +1720,18 @@ namespace Emby.Server.Implementations.Data
                 {
                 {
                     if (!reader.IsDBNull(index))
                     if (!reader.IsDBNull(index))
                     {
                     {
-                        trailer.TrailerTypes = reader.GetString(index).Split('|').Where(i => !string.IsNullOrWhiteSpace(i)).Select(i => (TrailerType)Enum.Parse(typeof(TrailerType), i, true)).ToList();
+                        trailer.TrailerTypes = reader.GetString(index).Split('|').Where(i => !string.IsNullOrWhiteSpace(i)).Select(
+                        i =>
+                        {
+                            TrailerType parsedValue;
+
+                            if (Enum.TryParse(i, true, out parsedValue))
+                            {
+                                return parsedValue;
+                            }
+                            return (TrailerType?)null;
+
+                        }).Where(i => i.HasValue).Select(i => i.Value).ToList();
                     }
                     }
                 }
                 }
                 index++;
                 index++;
@@ -1912,7 +1926,11 @@ namespace Emby.Server.Implementations.Data
 
 
             if (!reader.IsDBNull(index))
             if (!reader.IsDBNull(index))
             {
             {
-                item.ExtraType = (ExtraType)Enum.Parse(typeof(ExtraType), reader.GetString(index), true);
+                ExtraType extraType;
+                if (Enum.TryParse(reader.GetString(index), true, out extraType))
+                {
+                    item.ExtraType = extraType;
+                }
             }
             }
             index++;
             index++;
 
 
@@ -4444,21 +4462,27 @@ namespace Emby.Server.Implementations.Data
                 }
                 }
             }
             }
 
 
-            //var enableItemsByName = query.IncludeItemsByName ?? query.IncludeItemTypes.Length > 0;
-            var enableItemsByName = query.IncludeItemsByName ?? false;
+
+            var includedItemByNameTypes = GetItemByNameTypesInQuery(query).SelectMany(MapIncludeItemTypes).ToList();
+            var enableItemsByName = (query.IncludeItemsByName ?? false) && includedItemByNameTypes.Count > 0;
 
 
             var queryTopParentIds = query.TopParentIds.Where(IsValidId).ToArray();
             var queryTopParentIds = query.TopParentIds.Where(IsValidId).ToArray();
 
 
             if (queryTopParentIds.Length == 1)
             if (queryTopParentIds.Length == 1)
             {
             {
-                if (enableItemsByName)
+                if (enableItemsByName && includedItemByNameTypes.Count == 1)
                 {
                 {
-                    whereClauses.Add("(TopParentId=@TopParentId or IsItemByName=@IsItemByName)");
+                    whereClauses.Add("(TopParentId=@TopParentId or Type=@IncludedItemByNameType)");
                     if (statement != null)
                     if (statement != null)
                     {
                     {
-                        statement.TryBind("@IsItemByName", true);
+                        statement.TryBind("@IncludedItemByNameType", includedItemByNameTypes[0]);
                     }
                     }
                 }
                 }
+                else if (enableItemsByName && includedItemByNameTypes.Count > 1)
+                {
+                    var itemByNameTypeVal = string.Join(",", includedItemByNameTypes.Select(i => "'" + i + "'").ToArray());
+                    whereClauses.Add("(TopParentId=@TopParentId or Type in (" + itemByNameTypeVal + "))");
+                }
                 else
                 else
                 {
                 {
                     whereClauses.Add("(TopParentId=@TopParentId)");
                     whereClauses.Add("(TopParentId=@TopParentId)");
@@ -4472,14 +4496,19 @@ namespace Emby.Server.Implementations.Data
             {
             {
                 var val = string.Join(",", queryTopParentIds.Select(i => "'" + i + "'").ToArray());
                 var val = string.Join(",", queryTopParentIds.Select(i => "'" + i + "'").ToArray());
 
 
-                if (enableItemsByName)
+                if (enableItemsByName && includedItemByNameTypes.Count == 1)
                 {
                 {
-                    whereClauses.Add("(IsItemByName=@IsItemByName or TopParentId in (" + val + "))");
+                    whereClauses.Add("(Type=@IncludedItemByNameType or TopParentId in (" + val + "))");
                     if (statement != null)
                     if (statement != null)
                     {
                     {
-                        statement.TryBind("@IsItemByName", true);
+                        statement.TryBind("@IncludedItemByNameType", includedItemByNameTypes[0]);
                     }
                     }
                 }
                 }
+                else if (enableItemsByName && includedItemByNameTypes.Count > 1)
+                {
+                    var itemByNameTypeVal = string.Join(",", includedItemByNameTypes.Select(i => "'" + i + "'").ToArray());
+                    whereClauses.Add("(Type in (" + itemByNameTypeVal + ") or TopParentId in (" + val + "))");
+                }
                 else
                 else
                 {
                 {
                     whereClauses.Add("(TopParentId in (" + val + "))");
                     whereClauses.Add("(TopParentId in (" + val + "))");
@@ -4559,6 +4588,48 @@ namespace Emby.Server.Implementations.Data
             return whereClauses;
             return whereClauses;
         }
         }
 
 
+        private List<string> GetItemByNameTypesInQuery(InternalItemsQuery query)
+        {
+            var list = new List<string>();
+
+            if (IsTypeInQuery(typeof(Person).Name, query))
+            {
+                list.Add(typeof(Person).Name);
+            }
+            if (IsTypeInQuery(typeof(Genre).Name, query))
+            {
+                list.Add(typeof(Genre).Name);
+            }
+            if (IsTypeInQuery(typeof(MusicGenre).Name, query))
+            {
+                list.Add(typeof(MusicGenre).Name);
+            }
+            if (IsTypeInQuery(typeof(GameGenre).Name, query))
+            {
+                list.Add(typeof(GameGenre).Name);
+            }
+            if (IsTypeInQuery(typeof(MusicArtist).Name, query))
+            {
+                list.Add(typeof(MusicArtist).Name);
+            }
+            if (IsTypeInQuery(typeof(Studio).Name, query))
+            {
+                list.Add(typeof(Studio).Name);
+            }
+
+            return list;
+        }
+
+        private bool IsTypeInQuery(string type, InternalItemsQuery query)
+        {
+            if (query.ExcludeItemTypes.Contains(type, StringComparer.OrdinalIgnoreCase))
+            {
+                return false;
+            }
+
+            return query.IncludeItemTypes.Length == 0 || query.IncludeItemTypes.Contains(type, StringComparer.OrdinalIgnoreCase);
+        }
+
         private string GetCleanValue(string value)
         private string GetCleanValue(string value)
         {
         {
             if (string.IsNullOrWhiteSpace(value))
             if (string.IsNullOrWhiteSpace(value))

+ 12 - 8
Emby.Server.Implementations/Library/ResolverHelper.cs

@@ -46,7 +46,7 @@ namespace Emby.Server.Implementations.Library
             var fileInfo = directoryService.GetFile(item.Path);
             var fileInfo = directoryService.GetFile(item.Path);
             SetDateCreated(item, fileSystem, fileInfo);
             SetDateCreated(item, fileSystem, fileInfo);
 
 
-            EnsureName(item, fileInfo);
+            EnsureName(item, item.Path, fileInfo);
         }
         }
 
 
         /// <summary>
         /// <summary>
@@ -73,7 +73,7 @@ namespace Emby.Server.Implementations.Library
             item.Id = libraryManager.GetNewItemId(item.Path, item.GetType());
             item.Id = libraryManager.GetNewItemId(item.Path, item.GetType());
 
 
             // Make sure the item has a name
             // Make sure the item has a name
-            EnsureName(item, args.FileInfo);
+            EnsureName(item, item.Path, args.FileInfo);
 
 
             item.IsLocked = item.Path.IndexOf("[dontfetchmeta]", StringComparison.OrdinalIgnoreCase) != -1 ||
             item.IsLocked = item.Path.IndexOf("[dontfetchmeta]", StringComparison.OrdinalIgnoreCase) != -1 ||
                 item.GetParents().Any(i => i.IsLocked);
                 item.GetParents().Any(i => i.IsLocked);
@@ -85,14 +85,14 @@ namespace Emby.Server.Implementations.Library
         /// <summary>
         /// <summary>
         /// Ensures the name.
         /// Ensures the name.
         /// </summary>
         /// </summary>
-        /// <param name="item">The item.</param>
-        /// <param name="fileInfo">The file information.</param>
-        private static void EnsureName(BaseItem item, FileSystemMetadata fileInfo)
+        private static void EnsureName(BaseItem item, string fullPath, FileSystemMetadata fileInfo)
         {
         {
             // If the subclass didn't supply a name, add it here
             // If the subclass didn't supply a name, add it here
-            if (string.IsNullOrEmpty(item.Name) && !string.IsNullOrEmpty(item.Path))
+            if (string.IsNullOrEmpty(item.Name) && !string.IsNullOrEmpty(fullPath))
             {
             {
-                item.Name = GetDisplayName(fileInfo.Name, fileInfo.IsDirectory);
+                var fileName = fileInfo == null ? Path.GetFileName(fullPath) : fileInfo.Name;
+
+                item.Name = GetDisplayName(fileName, fileInfo != null && fileInfo.IsDirectory);
             }
             }
         }
         }
 
 
@@ -170,7 +170,11 @@ namespace Emby.Server.Implementations.Library
 
 
             if (config.UseFileCreationTimeForDateAdded)
             if (config.UseFileCreationTimeForDateAdded)
             {
             {
-                item.DateCreated = fileSystem.GetCreationTimeUtc(info);
+                // directoryService.getFile may return null
+                if (info != null)
+                {
+                    item.DateCreated = fileSystem.GetCreationTimeUtc(info);
+                }
             }
             }
             else
             else
             {
             {

+ 0 - 15
MediaBrowser.Controller/Library/ItemResolveArgs.cs

@@ -237,21 +237,6 @@ namespace MediaBrowser.Controller.Library
             return null;
             return null;
         }
         }
 
 
-        /// <summary>
-        /// Determines whether [contains meta file by name] [the specified name].
-        /// </summary>
-        /// <param name="name">The name.</param>
-        /// <returns><c>true</c> if [contains meta file by name] [the specified name]; otherwise, <c>false</c>.</returns>
-        public bool ContainsMetaFileByName(string name)
-        {
-            if (string.IsNullOrEmpty(name))
-            {
-                throw new ArgumentNullException();
-            }
-
-            return GetFileSystemEntryByName(name) != null;
-        }
-
         /// <summary>
         /// <summary>
         /// Determines whether [contains file system entry by name] [the specified name].
         /// Determines whether [contains file system entry by name] [the specified name].
         /// </summary>
         /// </summary>

+ 4 - 0
MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs

@@ -205,6 +205,10 @@ namespace MediaBrowser.Controller.MediaEncoding
             {
             {
                 return null;
                 return null;
             }
             }
+            if (string.Equals(container, "rmvb", StringComparison.OrdinalIgnoreCase))
+            {
+                return null;
+            }
 
 
             // Seeing reported failures here, not sure yet if this is related to specfying input format
             // Seeing reported failures here, not sure yet if this is related to specfying input format
             if (string.Equals(container, "m4v", StringComparison.OrdinalIgnoreCase))
             if (string.Equals(container, "m4v", StringComparison.OrdinalIgnoreCase))

+ 1 - 1
SharedVersion.cs

@@ -1,3 +1,3 @@
 using System.Reflection;
 using System.Reflection;
 
 
-[assembly: AssemblyVersion("3.2.26.2")]
+[assembly: AssemblyVersion("3.2.26.3")]