diff options
| author | LukePulverenti Luke Pulverenti luke pulverenti <LukePulverenti Luke Pulverenti luke.pulverenti@gmail.com> | 2012-08-21 22:50:59 -0400 |
|---|---|---|
| committer | LukePulverenti Luke Pulverenti luke pulverenti <LukePulverenti Luke Pulverenti luke.pulverenti@gmail.com> | 2012-08-21 22:50:59 -0400 |
| commit | fbf8cc833c441de8890998600be044296acfc783 (patch) | |
| tree | d2980ddcbf5987f805916842f975795d9cabce83 /MediaBrowser.Controller/FFMpeg/FFProbe.cs | |
| parent | 1c5f728ec252f7a146b7e6fa1b409e2ca3f8d920 (diff) | |
a few more async optimizations
Diffstat (limited to 'MediaBrowser.Controller/FFMpeg/FFProbe.cs')
| -rw-r--r-- | MediaBrowser.Controller/FFMpeg/FFProbe.cs | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/MediaBrowser.Controller/FFMpeg/FFProbe.cs b/MediaBrowser.Controller/FFMpeg/FFProbe.cs index f5364821c..1a0685a7a 100644 --- a/MediaBrowser.Controller/FFMpeg/FFProbe.cs +++ b/MediaBrowser.Controller/FFMpeg/FFProbe.cs @@ -18,10 +18,7 @@ namespace MediaBrowser.Controller.FFMpeg // Use try catch to avoid having to use File.Exists
try
{
- using (FileStream stream = File.OpenRead(outputCachePath))
- {
- return JsonSerializer.DeserializeFromStream<FFProbeResult>(stream);
- }
+ return GetCachedResult(outputCachePath);
}
catch (FileNotFoundException)
{
@@ -29,7 +26,12 @@ namespace MediaBrowser.Controller.FFMpeg await Run(item.Path, outputCachePath).ConfigureAwait(false);
- using (FileStream stream = File.OpenRead(outputCachePath))
+ return GetCachedResult(item.Path);
+ }
+
+ public static FFProbeResult GetCachedResult(string path)
+ {
+ using (FileStream stream = File.OpenRead(path))
{
return JsonSerializer.DeserializeFromStream<FFProbeResult>(stream);
}
@@ -40,10 +42,7 @@ namespace MediaBrowser.Controller.FFMpeg // Use try catch to avoid having to use File.Exists
try
{
- using (FileStream stream = File.OpenRead(outputCachePath))
- {
- return JsonSerializer.DeserializeFromStream<FFProbeResult>(stream);
- }
+ return GetCachedResult(outputCachePath);
}
catch (FileNotFoundException)
{
@@ -51,10 +50,7 @@ namespace MediaBrowser.Controller.FFMpeg await Run(item.Path, outputCachePath).ConfigureAwait(false);
- using (FileStream stream = File.OpenRead(outputCachePath))
- {
- return JsonSerializer.DeserializeFromStream<FFProbeResult>(stream);
- }
+ return GetCachedResult(item.Path);
}
private async static Task Run(string input, string output)
|
