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 *.pubxml
# NuGet Packages Directory # NuGet Packages Directory
## TODO: If you have NuGet Package Restore enabled, uncomment the next line
# packages/
dlls/ dlls/
dllssigned/ dllssigned/

View File

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

View File

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

View File

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

View File

@ -1176,24 +1176,6 @@ namespace MediaBrowser.Controller.MediaEncoding
":fontsdir='{0}'", ":fontsdir='{0}'",
_mediaEncoder.EscapeSubtitleFilterPath(fontPath)); _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) if (state.SubtitleStream.IsExternal)
{ {
var charsetParam = string.Empty; var charsetParam = string.Empty;
@ -1221,7 +1203,6 @@ namespace MediaBrowser.Controller.MediaEncoding
alphaParam, alphaParam,
sub2videoParam, sub2videoParam,
fontParam, fontParam,
// fallbackFontParam,
setPtsParam); setPtsParam);
} }

View File

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

View File

@ -128,9 +128,7 @@ namespace Jellyfin.Extensions
return result; 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); } while (pos1 < len1 && pos2 < len2);
#pragma warning restore SA1500
return len1 - len2; return len1 - len2;
} }

View File

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