Fix nullability errors in MediaBrowser.LocalMetadata

This commit is contained in:
crobibero 2020-11-13 08:31:02 -07:00
parent 9b7c5cddae
commit 38885ffd74
3 changed files with 9 additions and 3 deletions

View File

@ -486,7 +486,7 @@ namespace MediaBrowser.LocalMetadata.Images
return false; return false;
} }
private FileSystemMetadata GetImage(IEnumerable<FileSystemMetadata> files, string name) private FileSystemMetadata? GetImage(IEnumerable<FileSystemMetadata> files, string name)
{ {
return files.FirstOrDefault(i => !i.IsDirectory && string.Equals(name, _fileSystem.GetFileNameWithoutExtension(i), StringComparison.OrdinalIgnoreCase) && i.Length > 0); return files.FirstOrDefault(i => !i.IsDirectory && string.Equals(name, _fileSystem.GetFileNameWithoutExtension(i), StringComparison.OrdinalIgnoreCase) && i.Length > 0);
} }

View File

@ -683,7 +683,7 @@ namespace MediaBrowser.LocalMetadata.Parsers
default: default:
{ {
string readerName = reader.Name; string readerName = reader.Name;
if (_validProviderIds!.TryGetValue(readerName, out string providerIdValue)) if (_validProviderIds!.TryGetValue(readerName, out string? providerIdValue))
{ {
var id = reader.ReadElementContentAsString(); var id = reader.ReadElementContentAsString();
if (!string.IsNullOrWhiteSpace(id)) if (!string.IsNullOrWhiteSpace(id))

View File

@ -127,7 +127,13 @@ namespace MediaBrowser.LocalMetadata.Savers
private void SaveToFile(Stream stream, string path) private void SaveToFile(Stream stream, string path)
{ {
Directory.CreateDirectory(Path.GetDirectoryName(path)); var directory = Path.GetDirectoryName(path);
if (directory == null)
{
throw new NullReferenceException(nameof(directory));
}
Directory.CreateDirectory(directory);
// On Windows, savint the file will fail if the file is hidden or readonly // On Windows, savint the file will fail if the file is hidden or readonly
FileSystem.SetAttributes(path, false, false); FileSystem.SetAttributes(path, false, false);