Investigate some TODO comments

This commit is contained in:
Bond_009 2022-11-23 15:58:11 +01:00
parent e1bd5684e5
commit 556cc8062d
8 changed files with 26 additions and 47 deletions

2
.gitignore vendored
View File

@ -150,8 +150,6 @@ publish/
*.pubxml
# NuGet Packages Directory
## TODO: If you have NuGet Package Restore enabled, uncomment the next line
# packages/
dlls/
dllssigned/

View File

@ -338,7 +338,6 @@ namespace Emby.Dlna.PlayTo
SubtitleStreamIndex = info.SubtitleStreamIndex,
VolumeLevel = _device.Volume,
// TODO
CanSeek = true,
PlayMethod = info.IsDirectStream ? PlayMethod.DirectStream : PlayMethod.Transcode

View File

@ -31,16 +31,18 @@ namespace Emby.Server.Implementations.Library.Resolvers
if (args.IsDirectory)
{
// It's a boxset if the path is a directory with [playlist] in it's the name
// TODO: Should this use Path.GetDirectoryName() instead?
bool isBoxSet = Path.GetFileName(args.Path)
?.Contains("[playlist]", StringComparison.OrdinalIgnoreCase)
?? false;
if (isBoxSet)
var filename = Path.GetFileName(Path.TrimEndingDirectorySeparator(args.Path));
if (string.IsNullOrEmpty(filename))
{
return null;
}
if (filename.Contains("[playlist]", StringComparison.OrdinalIgnoreCase))
{
return new Playlist
{
Path = args.Path,
Name = Path.GetFileName(args.Path).Replace("[playlist]", string.Empty, StringComparison.OrdinalIgnoreCase).Trim()
Name = filename.Replace("[playlist]", string.Empty, StringComparison.OrdinalIgnoreCase).Trim()
};
}
@ -51,7 +53,7 @@ namespace Emby.Server.Implementations.Library.Resolvers
return new Playlist
{
Path = args.Path,
Name = Path.GetFileName(args.Path)
Name = filename
};
}
}
@ -60,8 +62,8 @@ namespace Emby.Server.Implementations.Library.Resolvers
// It should have the correct collection type and a supported file extension
else if (_musicPlaylistCollectionTypes.Contains(args.CollectionType ?? string.Empty, StringComparison.OrdinalIgnoreCase))
{
var extension = Path.GetExtension(args.Path);
if (Playlist.SupportedExtensions.Contains(extension ?? string.Empty, StringComparison.OrdinalIgnoreCase))
var extension = Path.GetExtension(args.Path.AsSpan());
if (Playlist.SupportedExtensions.Contains(extension, StringComparison.OrdinalIgnoreCase))
{
return new Playlist
{

View File

@ -16,6 +16,7 @@ using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Globalization;
using MediaBrowser.Model.IO;
using MediaBrowser.Model.Tasks;
using Microsoft.Extensions.Logging;
namespace Emby.Server.Implementations.ScheduledTasks.Tasks
{
@ -24,15 +25,10 @@ namespace Emby.Server.Implementations.ScheduledTasks.Tasks
/// </summary>
public class ChapterImagesTask : IScheduledTask
{
/// <summary>
/// The _library manager.
/// </summary>
private readonly ILogger _logger;
private readonly ILibraryManager _libraryManager;
private readonly IItemRepository _itemRepo;
private readonly IApplicationPaths _appPaths;
private readonly IEncodingManager _encodingManager;
private readonly IFileSystem _fileSystem;
private readonly ILocalizationManager _localization;
@ -40,6 +36,7 @@ namespace Emby.Server.Implementations.ScheduledTasks.Tasks
/// <summary>
/// Initializes a new instance of the <see cref="ChapterImagesTask" /> class.
/// </summary>
/// <param name="logger">The logger.</param>.
/// <param name="libraryManager">The library manager.</param>.
/// <param name="itemRepo">The item repository.</param>
/// <param name="appPaths">The application paths.</param>
@ -47,6 +44,7 @@ namespace Emby.Server.Implementations.ScheduledTasks.Tasks
/// <param name="fileSystem">The filesystem.</param>
/// <param name="localization">The localization manager.</param>
public ChapterImagesTask(
ILogger<ChapterImagesTask> logger,
ILibraryManager libraryManager,
IItemRepository itemRepo,
IApplicationPaths appPaths,
@ -54,6 +52,7 @@ namespace Emby.Server.Implementations.ScheduledTasks.Tasks
IFileSystem fileSystem,
ILocalizationManager localization)
{
_logger = logger;
_libraryManager = libraryManager;
_itemRepo = itemRepo;
_appPaths = appPaths;
@ -167,9 +166,10 @@ namespace Emby.Server.Implementations.ScheduledTasks.Tasks
progress.Report(100 * percent);
}
catch (ObjectDisposedException)
catch (ObjectDisposedException ex)
{
// TODO Investigate and properly fix.
_logger.LogError(ex, "Object Disposed");
break;
}
}

View File

@ -1176,24 +1176,6 @@ namespace MediaBrowser.Controller.MediaEncoding
":fontsdir='{0}'",
_mediaEncoder.EscapeSubtitleFilterPath(fontPath));
// TODO
// var fallbackFontPath = Path.Combine(_appPaths.ProgramDataPath, "fonts", "DroidSansFallback.ttf");
// string fallbackFontParam = string.Empty;
// if (!File.Exists(fallbackFontPath))
// {
// _fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(fallbackFontPath));
// using (var stream = _assemblyInfo.GetManifestResourceStream(GetType(), GetType().Namespace + ".DroidSansFallback.ttf"))
// {
// using (var fileStream = new FileStream(fallbackFontPath, FileMode.Create, FileAccess.Write, FileShare.Read))
// {
// stream.CopyTo(fileStream);
// }
// }
// }
// fallbackFontParam = string.Format(CultureInfo.InvariantCulture, ":force_style='FontName=Droid Sans Fallback':fontsdir='{0}'", _mediaEncoder.EscapeSubtitleFilterPath(_fileSystem.GetDirectoryName(fallbackFontPath)));
if (state.SubtitleStream.IsExternal)
{
var charsetParam = string.Empty;
@ -1221,7 +1203,6 @@ namespace MediaBrowser.Controller.MediaEncoding
alphaParam,
sub2videoParam,
fontParam,
// fallbackFontParam,
setPtsParam);
}

View File

@ -227,9 +227,10 @@ namespace MediaBrowser.Controller.Net
connection.Item2.Cancel();
connection.Item2.Dispose();
}
catch (ObjectDisposedException)
catch (ObjectDisposedException ex)
{
// TODO Investigate and properly fix.
Logger.LogError(ex, "Object Disposed");
}
lock (_activeConnections)

View File

@ -128,9 +128,7 @@ namespace Jellyfin.Extensions
return result;
}
}
#pragma warning disable SA1500 // TODO remove with StyleCop.Analyzers v1.2.0 https://github.com/DotNetAnalyzers/StyleCopAnalyzers/pull/3196
} while (pos1 < len1 && pos2 < len2);
#pragma warning restore SA1500
return len1 - len2;
}

View File

@ -359,7 +359,7 @@ namespace Jellyfin.Model.Tests
Assert.Single(val.TargetAudioCodec);
// Assert.Single(val.AudioCodecs);
if (transcodeMode == "DirectStream")
if (transcodeMode.Equals("DirectStream", StringComparison.Ordinal))
{
Assert.Equal(val.Container, uri.Extension);
}
@ -371,14 +371,14 @@ namespace Jellyfin.Model.Tests
Assert.NotEmpty(val.AudioCodecs);
// Check expected container (todo: this could be a test param)
if (transcodeProtocol == "http")
if (transcodeProtocol.Equals("http", StringComparison.Ordinal))
{
// Assert.Equal("webm", val.Container);
Assert.Equal(val.Container, uri.Extension);
Assert.Equal("stream", uri.Filename);
Assert.Equal("http", val.SubProtocol);
}
else if (transcodeProtocol == "HLS.mp4")
else if (transcodeProtocol.Equals("HLS.mp4", StringComparison.Ordinal))
{
Assert.Equal("mp4", val.Container);
Assert.Equal("m3u8", uri.Extension);
@ -394,7 +394,7 @@ namespace Jellyfin.Model.Tests
}
// Full transcode
if (transcodeMode == "Transcode")
if (transcodeMode.Equals("Transcode", StringComparison.Ordinal))
{
if ((val.TranscodeReasons & (StreamBuilder.ContainerReasons | TranscodeReason.DirectPlayError)) == 0)
{
@ -413,7 +413,7 @@ namespace Jellyfin.Model.Tests
Assert.Contains(targetVideoStream.Codec, val.TargetVideoCodec);
Assert.Single(val.TargetVideoCodec);
if (transcodeMode == "DirectStream")
if (transcodeMode.Equals("DirectStream", StringComparison.Ordinal))
{
// Check expected audio codecs (1)
if (!targetAudioStream.IsExternal)
@ -428,7 +428,7 @@ namespace Jellyfin.Model.Tests
}
}
}
else if (transcodeMode == "Remux")
else if (transcodeMode.Equals("Remux", StringComparison.Ordinal))
{
// Check expected audio codecs (1)
Assert.Contains(targetAudioStream.Codec, val.AudioCodecs);