Return path of extracted attachment, which is always a file, instead of AttachmentInfo with path and protocol.

This commit is contained in:
Andrew Mahone 2019-11-04 14:48:28 -05:00
parent 04a96788f9
commit 28a6718d8e

View File

@ -97,20 +97,19 @@ namespace MediaBrowser.MediaEncoding.Attachments
CancellationToken cancellationToken) CancellationToken cancellationToken)
{ {
var inputFiles = new[] {mediaSource.Path}; var inputFiles = new[] {mediaSource.Path};
var fileInfo = await GetReadableFile(mediaSource.Path, inputFiles, mediaSource.Protocol, mediaAttachment, cancellationToken).ConfigureAwait(false); var attachmentPath = await GetReadableFile(mediaSource.Path, inputFiles, mediaSource.Protocol, mediaAttachment, cancellationToken).ConfigureAwait(false);
var stream = await GetAttachmentStream(fileInfo.Path, fileInfo.Protocol, cancellationToken).ConfigureAwait(false); var stream = await GetAttachmentStream(attachmentPath, cancellationToken).ConfigureAwait(false);
return stream; return stream;
} }
private async Task<Stream> GetAttachmentStream( private async Task<Stream> GetAttachmentStream(
string path, string path,
MediaProtocol protocol,
CancellationToken cancellationToken) CancellationToken cancellationToken)
{ {
return File.OpenRead(path); return File.OpenRead(path);
} }
private async Task<AttachmentInfo> GetReadableFile( private async Task<String> GetReadableFile(
string mediaPath, string mediaPath,
string[] inputFiles, string[] inputFiles,
MediaProtocol protocol, MediaProtocol protocol,
@ -121,18 +120,7 @@ namespace MediaBrowser.MediaEncoding.Attachments
await ExtractAttachment(inputFiles, protocol, mediaAttachment.Index, outputPath, cancellationToken) await ExtractAttachment(inputFiles, protocol, mediaAttachment.Index, outputPath, cancellationToken)
.ConfigureAwait(false); .ConfigureAwait(false);
return new AttachmentInfo(outputPath, MediaProtocol.File); return outputPath;
}
private struct AttachmentInfo
{
public AttachmentInfo(string path, MediaProtocol protocol)
{
Path = path;
Protocol = protocol;
}
public string Path { get; set; }
public MediaProtocol Protocol { get; set; }
} }
private readonly ConcurrentDictionary<string, SemaphoreSlim> _semaphoreLocks = private readonly ConcurrentDictionary<string, SemaphoreSlim> _semaphoreLocks =