add some safe guards with linked children & shortcuts

This commit is contained in:
Luke Pulverenti 2013-09-08 13:55:37 -04:00
parent aa03e8e14a
commit 52ca9527cc

View File

@ -1020,6 +1020,11 @@ namespace MediaBrowser.Controller.Entities
/// <returns>BaseItem.</returns> /// <returns>BaseItem.</returns>
private BaseItem GetLinkedChild(LinkedChild info) private BaseItem GetLinkedChild(LinkedChild info)
{ {
if (string.IsNullOrEmpty(info.Path))
{
throw new ArgumentException("Encountered linked child with empty path.");
}
var item = LibraryManager.RootFolder.FindByPath(info.Path); var item = LibraryManager.RootFolder.FindByPath(info.Path);
if (item == null) if (item == null)
@ -1071,12 +1076,21 @@ namespace MediaBrowser.Controller.Entities
{ {
Logger.Debug("Found shortcut at {0}", i.FullName); Logger.Debug("Found shortcut at {0}", i.FullName);
var resolvedPath = FileSystem.ResolveShortcut(i.FullName);
if (!string.IsNullOrEmpty(resolvedPath))
{
return new LinkedChild return new LinkedChild
{ {
Path = FileSystem.ResolveShortcut(i.FullName), Path = resolvedPath,
Type = LinkedChildType.Shortcut Type = LinkedChildType.Shortcut
}; };
} }
Logger.Error("Error resolving shortcut {0}", i.FullName);
return null;
}
catch (IOException ex) catch (IOException ex)
{ {
Logger.ErrorException("Error resolving shortcut {0}", ex, i.FullName); Logger.ErrorException("Error resolving shortcut {0}", ex, i.FullName);