Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid causing exceptions when item has no file path #1

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions NfoMetadata/Providers/BaseNfoProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

namespace NfoMetadata.Providers
{
using MediaBrowser.Model.MediaInfo;

public abstract class BaseNfoProvider<T> : ILocalMetadataProvider<T>, IHasItemChangeMonitor, IHasMetadataFeatures
where T : BaseItem, new()
{
Expand All @@ -18,6 +20,11 @@ public async Task<MetadataResult<T>> GetMetadata(ItemInfo info, LibraryOptions l
{
var result = new MetadataResult<T>();

if (string.IsNullOrEmpty(info.Path))
{
return result;
}

var file = GetXmlFile(info, libraryOptions, directoryService);

if (file == null)
Expand Down Expand Up @@ -59,6 +66,11 @@ protected BaseNfoProvider(IFileSystem fileSystem)

public bool HasChanged(BaseItem item, LibraryOptions libraryOptions, IDirectoryService directoryService)
{
if (string.IsNullOrEmpty(item.Path) || item.PathProtocol.HasValue && item.PathProtocol != MediaProtocol.File)
{
return false;
}

var file = GetXmlFile(new ItemInfo(item), libraryOptions, directoryService);

if (file == null)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
# MusicBrainz
# NfoMetadata