mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-09-06 03:26:07 +02:00
perform downloads in parallel
This commit is contained in:
parent
1c2be7ba67
commit
1dbce6bff2
1 changed files with 35 additions and 22 deletions
|
@ -7,6 +7,7 @@ using SharpCompress.Archive.SevenZip;
|
||||||
using SharpCompress.Common;
|
using SharpCompress.Common;
|
||||||
using SharpCompress.Reader;
|
using SharpCompress.Reader;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
@ -54,19 +55,16 @@ namespace MediaBrowser.ServerApplication.Implementations
|
||||||
Directory.CreateDirectory(versionedDirectoryPath);
|
Directory.CreateDirectory(versionedDirectoryPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var tasks = new List<Task>();
|
||||||
|
|
||||||
if (!File.Exists(info.ProbePath) || !File.Exists(info.Path))
|
if (!File.Exists(info.ProbePath) || !File.Exists(info.Path))
|
||||||
{
|
{
|
||||||
await DownloadFFMpeg(info).ConfigureAwait(false);
|
tasks.Add(DownloadFFMpeg(info));
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
tasks.Add(DownloadFonts(versionedDirectoryPath));
|
||||||
{
|
|
||||||
await DownloadFonts(versionedDirectoryPath).ConfigureAwait(false);
|
await Task.WhenAll(tasks).ConfigureAwait(false);
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.ErrorException("Error getting ffmpeg font files", ex);
|
|
||||||
}
|
|
||||||
|
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
@ -87,6 +85,8 @@ namespace MediaBrowser.ServerApplication.Implementations
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
throw new ApplicationException("Unable to download required components. Please try again later.");
|
||||||
}
|
}
|
||||||
|
|
||||||
private Task<string> DownloadFFMpeg(FFMpegInfo info, string url)
|
private Task<string> DownloadFFMpeg(FFMpegInfo info, string url)
|
||||||
|
@ -160,23 +160,36 @@ namespace MediaBrowser.ServerApplication.Implementations
|
||||||
/// <param name="targetPath">The target path.</param>
|
/// <param name="targetPath">The target path.</param>
|
||||||
private async Task DownloadFonts(string targetPath)
|
private async Task DownloadFonts(string targetPath)
|
||||||
{
|
{
|
||||||
var fontsDirectory = Path.Combine(targetPath, "fonts");
|
try
|
||||||
|
|
||||||
if (!Directory.Exists(fontsDirectory))
|
|
||||||
{
|
{
|
||||||
Directory.CreateDirectory(fontsDirectory);
|
var fontsDirectory = Path.Combine(targetPath, "fonts");
|
||||||
|
|
||||||
|
if (!Directory.Exists(fontsDirectory))
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(fontsDirectory);
|
||||||
|
}
|
||||||
|
|
||||||
|
const string fontFilename = "ARIALUNI.TTF";
|
||||||
|
|
||||||
|
var fontFile = Path.Combine(fontsDirectory, fontFilename);
|
||||||
|
|
||||||
|
if (!File.Exists(fontFile))
|
||||||
|
{
|
||||||
|
await DownloadFontFile(fontsDirectory, fontFilename).ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
await WriteFontConfigFile(fontsDirectory).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
catch (HttpException ex)
|
||||||
const string fontFilename = "ARIALUNI.TTF";
|
|
||||||
|
|
||||||
var fontFile = Path.Combine(fontsDirectory, fontFilename);
|
|
||||||
|
|
||||||
if (!File.Exists(fontFile))
|
|
||||||
{
|
{
|
||||||
await DownloadFontFile(fontsDirectory, fontFilename).ConfigureAwait(false);
|
// Don't let the server crash because of this
|
||||||
|
_logger.ErrorException("Error downloading ffmpeg font files", ex);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
// Don't let the server crash because of this
|
||||||
|
_logger.ErrorException("Error writing ffmpeg font files", ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
await WriteFontConfigFile(fontsDirectory).ConfigureAwait(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
Loading…
Reference in a new issue