mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-07-09 03:04:24 -04:00
add error handling
This commit is contained in:
parent
c27bc3de13
commit
d15eb59635
@ -60,10 +60,6 @@ namespace MediaBrowser.Server.Startup.Common.FFMpeg
|
|||||||
var downloadInfo = _ffmpegInstallInfo;
|
var downloadInfo = _ffmpegInstallInfo;
|
||||||
|
|
||||||
var version = downloadInfo.Version;
|
var version = downloadInfo.Version;
|
||||||
if (string.Equals(version, "0", StringComparison.OrdinalIgnoreCase))
|
|
||||||
{
|
|
||||||
return new FFMpegInfo();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (string.Equals(version, "path", StringComparison.OrdinalIgnoreCase))
|
if (string.Equals(version, "path", StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
@ -75,6 +71,11 @@ namespace MediaBrowser.Server.Startup.Common.FFMpeg
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (string.Equals(version, "0", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
return new FFMpegInfo();
|
||||||
|
}
|
||||||
|
|
||||||
var rootEncoderPath = Path.Combine(_appPaths.ProgramDataPath, "ffmpeg");
|
var rootEncoderPath = Path.Combine(_appPaths.ProgramDataPath, "ffmpeg");
|
||||||
var versionedDirectoryPath = Path.Combine(rootEncoderPath, version);
|
var versionedDirectoryPath = Path.Combine(rootEncoderPath, version);
|
||||||
|
|
||||||
@ -97,7 +98,11 @@ namespace MediaBrowser.Server.Startup.Common.FFMpeg
|
|||||||
// No older version. Need to download and block until complete
|
// No older version. Need to download and block until complete
|
||||||
if (existingVersion == null)
|
if (existingVersion == null)
|
||||||
{
|
{
|
||||||
await DownloadFFMpeg(downloadInfo, versionedDirectoryPath, progress).ConfigureAwait(false);
|
var success = await DownloadFFMpeg(downloadInfo, versionedDirectoryPath, progress).ConfigureAwait(false);
|
||||||
|
if (!success)
|
||||||
|
{
|
||||||
|
return new FFMpegInfo();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -179,7 +184,7 @@ namespace MediaBrowser.Server.Startup.Common.FFMpeg
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task DownloadFFMpeg(FFMpegInstallInfo downloadinfo, string directory, IProgress<double> progress)
|
private async Task<bool> DownloadFFMpeg(FFMpegInstallInfo downloadinfo, string directory, IProgress<double> progress)
|
||||||
{
|
{
|
||||||
foreach (var url in downloadinfo.DownloadUrls)
|
foreach (var url in downloadinfo.DownloadUrls)
|
||||||
{
|
{
|
||||||
@ -196,13 +201,14 @@ namespace MediaBrowser.Server.Startup.Common.FFMpeg
|
|||||||
}).ConfigureAwait(false);
|
}).ConfigureAwait(false);
|
||||||
|
|
||||||
ExtractFFMpeg(downloadinfo, tempFile, directory);
|
ExtractFFMpeg(downloadinfo, tempFile, directory);
|
||||||
return;
|
return true;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.ErrorException("Error downloading {0}", ex, url);
|
_logger.ErrorException("Error downloading {0}", ex, url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ExtractFFMpeg(FFMpegInstallInfo downloadinfo, string tempFile, string targetFolder)
|
private void ExtractFFMpeg(FFMpegInstallInfo downloadinfo, string tempFile, string targetFolder)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user