aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--MediaBrowser.Server.Implementations/MediaEncoder/MediaEncoder.cs41
1 files changed, 32 insertions, 9 deletions
diff --git a/MediaBrowser.Server.Implementations/MediaEncoder/MediaEncoder.cs b/MediaBrowser.Server.Implementations/MediaEncoder/MediaEncoder.cs
index 2ce49aabb..1eeade08d 100644
--- a/MediaBrowser.Server.Implementations/MediaEncoder/MediaEncoder.cs
+++ b/MediaBrowser.Server.Implementations/MediaEncoder/MediaEncoder.cs
@@ -236,26 +236,49 @@ namespace MediaBrowser.Server.Implementations.MediaEncoder
if (!File.Exists(fontFile))
{
- var tempFile = await _httpClient.GetTempFile(new HttpRequestOptions
- {
- Url = FontUrl,
- Progress = new Progress<double>()
- });
+ await DownloadFontFile(fontsDirectory, fontFilename).ConfigureAwait(false);
+ }
- _zipClient.ExtractAll(tempFile, fontsDirectory, true);
+ await WriteFontConfigFile(fontsDirectory).ConfigureAwait(false);
+ }
+ private async Task DownloadFontFile(string fontsDirectory, string fontFilename)
+ {
+ var existingFile = Directory
+ .EnumerateFiles(_appPaths.ProgramDataPath, fontFilename, SearchOption.AllDirectories)
+ .FirstOrDefault();
+
+ if (existingFile != null)
+ {
try
{
- File.Delete(tempFile);
+ File.Copy(existingFile, Path.Combine(fontsDirectory, fontFilename), true);
+ return;
}
catch (IOException ex)
{
// Log this, but don't let it fail the operation
- _logger.ErrorException("Error deleting temp file {0}", ex, tempFile);
+ _logger.ErrorException("Error copying file", ex);
}
}
- await WriteFontConfigFile(fontsDirectory).ConfigureAwait(false);
+ var tempFile = await _httpClient.GetTempFile(new HttpRequestOptions
+ {
+ Url = FontUrl,
+ Progress = new Progress<double>()
+ });
+
+ _zipClient.ExtractAll(tempFile, fontsDirectory, true);
+
+ try
+ {
+ File.Delete(tempFile);
+ }
+ catch (IOException ex)
+ {
+ // Log this, but don't let it fail the operation
+ _logger.ErrorException("Error deleting temp file {0}", ex, tempFile);
+ }
}
private async Task WriteFontConfigFile(string fontsDirectory)