mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-06-03 22:38:30 +01:00
3.2.26.3
This commit is contained in:
@@ -233,7 +233,6 @@ namespace Emby.Server.Implementations.Data
|
||||
AddColumn(db, "TypedBaseItems", "InheritedParentalRatingValue", "INT", existingColumnNames);
|
||||
AddColumn(db, "TypedBaseItems", "UnratedType", "Text", existingColumnNames);
|
||||
AddColumn(db, "TypedBaseItems", "TopParentId", "Text", existingColumnNames);
|
||||
AddColumn(db, "TypedBaseItems", "IsItemByName", "BIT", existingColumnNames);
|
||||
AddColumn(db, "TypedBaseItems", "TrailerTypes", "Text", existingColumnNames);
|
||||
AddColumn(db, "TypedBaseItems", "CriticRating", "Float", existingColumnNames);
|
||||
AddColumn(db, "TypedBaseItems", "InheritedTags", "Text", existingColumnNames);
|
||||
@@ -558,7 +557,6 @@ namespace Emby.Server.Implementations.Data
|
||||
"IsFolder",
|
||||
"UnratedType",
|
||||
"TopParentId",
|
||||
"IsItemByName",
|
||||
"TrailerTypes",
|
||||
"CriticRating",
|
||||
"InheritedTags",
|
||||
@@ -897,15 +895,6 @@ namespace Emby.Server.Implementations.Data
|
||||
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;
|
||||
if (trailer != null && trailer.TrailerTypes.Count > 0)
|
||||
{
|
||||
@@ -1656,7 +1645,11 @@ namespace Emby.Server.Implementations.Data
|
||||
|
||||
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++;
|
||||
|
||||
@@ -1687,7 +1680,17 @@ namespace Emby.Server.Implementations.Data
|
||||
{
|
||||
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++;
|
||||
}
|
||||
@@ -1717,7 +1720,18 @@ namespace Emby.Server.Implementations.Data
|
||||
{
|
||||
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++;
|
||||
@@ -1912,7 +1926,11 @@ namespace Emby.Server.Implementations.Data
|
||||
|
||||
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++;
|
||||
|
||||
@@ -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();
|
||||
|
||||
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)
|
||||
{
|
||||
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
|
||||
{
|
||||
whereClauses.Add("(TopParentId=@TopParentId)");
|
||||
@@ -4472,14 +4496,19 @@ namespace Emby.Server.Implementations.Data
|
||||
{
|
||||
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)
|
||||
{
|
||||
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
|
||||
{
|
||||
whereClauses.Add("(TopParentId in (" + val + "))");
|
||||
@@ -4559,6 +4588,48 @@ namespace Emby.Server.Implementations.Data
|
||||
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)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(value))
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace Emby.Server.Implementations.Library
|
||||
var fileInfo = directoryService.GetFile(item.Path);
|
||||
SetDateCreated(item, fileSystem, fileInfo);
|
||||
|
||||
EnsureName(item, fileInfo);
|
||||
EnsureName(item, item.Path, fileInfo);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -73,7 +73,7 @@ namespace Emby.Server.Implementations.Library
|
||||
item.Id = libraryManager.GetNewItemId(item.Path, item.GetType());
|
||||
|
||||
// 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.GetParents().Any(i => i.IsLocked);
|
||||
@@ -85,14 +85,14 @@ namespace Emby.Server.Implementations.Library
|
||||
/// <summary>
|
||||
/// Ensures the name.
|
||||
/// </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 (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)
|
||||
{
|
||||
item.DateCreated = fileSystem.GetCreationTimeUtc(info);
|
||||
// directoryService.getFile may return null
|
||||
if (info != null)
|
||||
{
|
||||
item.DateCreated = fileSystem.GetCreationTimeUtc(info);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user