Skip to content

Commit

Permalink
add FindByPath error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
LukePulverenti committed May 30, 2017
1 parent 340ac11 commit efff747
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 1 deletion.
5 changes: 5 additions & 0 deletions Emby.Server.Implementations/Collections/CollectionManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,11 @@ private async Task AddToCollection(Guid collectionId, IEnumerable<Guid> ids, boo
{
var item = _libraryManager.GetItemById(itemId);

if (string.IsNullOrWhiteSpace(item.Path))
{
continue;
}

if (item == null)
{
throw new ArgumentException("No item exists with the supplied Id");
Expand Down
5 changes: 5 additions & 0 deletions Emby.Server.Implementations/Library/LibraryManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -864,6 +864,11 @@ public BaseItem FindByPath(string path, bool? isFolder)
// 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

if (string.IsNullOrWhiteSpace(path))
{
throw new ArgumentNullException("path");
}

var query = new InternalItemsQuery
{
Path = path,
Expand Down
5 changes: 5 additions & 0 deletions Emby.Server.Implementations/Playlists/PlaylistManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,11 @@ private async Task AddToPlaylistInternal(string playlistId, IEnumerable<string>

foreach (var item in items)
{
if (string.IsNullOrWhiteSpace(item.Path))
{
continue;
}

list.Add(LinkedChild.Create(item));
}

Expand Down
18 changes: 18 additions & 0 deletions MediaBrowser.Api/UserLibrary/PlaystateService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,20 @@ private async Task<UserItemDataDto> MarkPlayed(MarkPlayedItem request)
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>
/// Posts the specified request.
/// </summary>
Expand All @@ -300,6 +314,8 @@ public void Post(OnPlaybackStart request)

public void Post(ReportPlaybackStart request)
{
request.PlayMethod = ValidatePlayMethod(request.PlayMethod, request.PlaySessionId);

request.SessionId = GetSession(_sessionContext).Result.Id;

var task = _sessionManager.OnPlaybackStart(request);
Expand Down Expand Up @@ -332,6 +348,8 @@ public void Post(OnPlaybackProgress request)

public void Post(ReportPlaybackProgress request)
{
request.PlayMethod = ValidatePlayMethod(request.PlayMethod, request.PlaySessionId);

request.SessionId = GetSession(_sessionContext).Result.Id;

var task = _sessionManager.OnPlaybackProgress(request);
Expand Down
2 changes: 1 addition & 1 deletion MediaBrowser.Controller/Entities/BaseItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1733,7 +1733,7 @@ protected BaseItem GetLinkedChild(LinkedChild info)

private BaseItem FindLinkedChild(LinkedChild info)
{
if (!string.IsNullOrEmpty(info.Path))
if (!string.IsNullOrWhiteSpace(info.Path))
{
var itemByPath = LibraryManager.FindByPath(info.Path, null);

Expand Down
Binary file modified ThirdParty/emby/Emby.Server.CinemaMode.dll
Binary file not shown.
Binary file modified ThirdParty/emby/Emby.Server.Sync.dll
Binary file not shown.

0 comments on commit efff747

Please sign in to comment.