add FindByPath error handling
This commit is contained in:
parent
01843ad4c3
commit
d8ec7109ab
|
@ -170,6 +170,11 @@ namespace Emby.Server.Implementations.Collections
|
||||||
{
|
{
|
||||||
var item = _libraryManager.GetItemById(itemId);
|
var item = _libraryManager.GetItemById(itemId);
|
||||||
|
|
||||||
|
if (string.IsNullOrWhiteSpace(item.Path))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (item == null)
|
if (item == null)
|
||||||
{
|
{
|
||||||
throw new ArgumentException("No item exists with the supplied Id");
|
throw new ArgumentException("No item exists with the supplied Id");
|
||||||
|
|
|
@ -864,6 +864,11 @@ namespace Emby.Server.Implementations.Library
|
||||||
// If this returns multiple items it could be tricky figuring out which one is correct.
|
// If this returns multiple items it could be tricky figuring out which one is correct.
|
||||||
// In most cases, the newest one will be and the others obsolete but not yet cleaned up
|
// In most cases, the newest one will be and the others obsolete but not yet cleaned up
|
||||||
|
|
||||||
|
if (string.IsNullOrWhiteSpace(path))
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("path");
|
||||||
|
}
|
||||||
|
|
||||||
var query = new InternalItemsQuery
|
var query = new InternalItemsQuery
|
||||||
{
|
{
|
||||||
Path = path,
|
Path = path,
|
||||||
|
|
|
@ -198,6 +198,11 @@ namespace Emby.Server.Implementations.Playlists
|
||||||
|
|
||||||
foreach (var item in items)
|
foreach (var item in items)
|
||||||
{
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(item.Path))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
list.Add(LinkedChild.Create(item));
|
list.Add(LinkedChild.Create(item));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -279,6 +279,20 @@ namespace MediaBrowser.Api.UserLibrary
|
||||||
return dto;
|
return dto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private PlayMethod ValidatePlayMethod(PlayMethod method, string playSessionId)
|
||||||
|
{
|
||||||
|
if (method == PlayMethod.Transcode)
|
||||||
|
{
|
||||||
|
var job = string.IsNullOrWhiteSpace(playSessionId) ? null : ApiEntryPoint.Instance.GetTranscodingJob(playSessionId);
|
||||||
|
if (job == null)
|
||||||
|
{
|
||||||
|
return PlayMethod.DirectPlay;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return method;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Posts the specified request.
|
/// Posts the specified request.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -300,6 +314,8 @@ namespace MediaBrowser.Api.UserLibrary
|
||||||
|
|
||||||
public void Post(ReportPlaybackStart request)
|
public void Post(ReportPlaybackStart request)
|
||||||
{
|
{
|
||||||
|
request.PlayMethod = ValidatePlayMethod(request.PlayMethod, request.PlaySessionId);
|
||||||
|
|
||||||
request.SessionId = GetSession(_sessionContext).Result.Id;
|
request.SessionId = GetSession(_sessionContext).Result.Id;
|
||||||
|
|
||||||
var task = _sessionManager.OnPlaybackStart(request);
|
var task = _sessionManager.OnPlaybackStart(request);
|
||||||
|
@ -332,6 +348,8 @@ namespace MediaBrowser.Api.UserLibrary
|
||||||
|
|
||||||
public void Post(ReportPlaybackProgress request)
|
public void Post(ReportPlaybackProgress request)
|
||||||
{
|
{
|
||||||
|
request.PlayMethod = ValidatePlayMethod(request.PlayMethod, request.PlaySessionId);
|
||||||
|
|
||||||
request.SessionId = GetSession(_sessionContext).Result.Id;
|
request.SessionId = GetSession(_sessionContext).Result.Id;
|
||||||
|
|
||||||
var task = _sessionManager.OnPlaybackProgress(request);
|
var task = _sessionManager.OnPlaybackProgress(request);
|
||||||
|
|
|
@ -1733,7 +1733,7 @@ namespace MediaBrowser.Controller.Entities
|
||||||
|
|
||||||
private BaseItem FindLinkedChild(LinkedChild info)
|
private BaseItem FindLinkedChild(LinkedChild info)
|
||||||
{
|
{
|
||||||
if (!string.IsNullOrEmpty(info.Path))
|
if (!string.IsNullOrWhiteSpace(info.Path))
|
||||||
{
|
{
|
||||||
var itemByPath = LibraryManager.FindByPath(info.Path, null);
|
var itemByPath = LibraryManager.FindByPath(info.Path, null);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user