diff options
| author | Bond_009 <bond.009@outlook.com> | 2024-10-31 17:02:06 +0100 |
|---|---|---|
| committer | Bond_009 <bond.009@outlook.com> | 2024-10-31 17:02:06 +0100 |
| commit | d2db7004024c6bbdd541a381c673f1e0b0aebfcb (patch) | |
| tree | 48d21b619b13c73fc85988d7c0b33a816b4f2c02 /Jellyfin.Server/Infrastructure/SymlinkFollowingPhysicalFileResultExecutor.cs | |
| parent | 282784cbb6fe203b87a6f2c673454ac8d3da82fa (diff) | |
Always await instead of directly returning Task
https://github.com/davidfowl/AspNetCoreDiagnosticScenarios/blob/master/AsyncGuidance.md#prefer-asyncawait-over-directly-returning-task
The performance impact is negligible (and it's me saying that!)
Diffstat (limited to 'Jellyfin.Server/Infrastructure/SymlinkFollowingPhysicalFileResultExecutor.cs')
| -rw-r--r-- | Jellyfin.Server/Infrastructure/SymlinkFollowingPhysicalFileResultExecutor.cs | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/Jellyfin.Server/Infrastructure/SymlinkFollowingPhysicalFileResultExecutor.cs b/Jellyfin.Server/Infrastructure/SymlinkFollowingPhysicalFileResultExecutor.cs index 801026c54..999e08384 100644 --- a/Jellyfin.Server/Infrastructure/SymlinkFollowingPhysicalFileResultExecutor.cs +++ b/Jellyfin.Server/Infrastructure/SymlinkFollowingPhysicalFileResultExecutor.cs @@ -67,38 +67,40 @@ namespace Jellyfin.Server.Infrastructure } /// <inheritdoc /> - protected override Task WriteFileAsync(ActionContext context, PhysicalFileResult result, RangeItemHeaderValue? range, long rangeLength) + protected override async Task WriteFileAsync(ActionContext context, PhysicalFileResult result, RangeItemHeaderValue? range, long rangeLength) { ArgumentNullException.ThrowIfNull(context); ArgumentNullException.ThrowIfNull(result); if (range is not null && rangeLength == 0) { - return Task.CompletedTask; + return; } // It's a bit of wasted IO to perform this check again, but non-symlinks shouldn't use this code if (!IsSymLink(result.FileName)) { - return base.WriteFileAsync(context, result, range, rangeLength); + await base.WriteFileAsync(context, result, range, rangeLength).ConfigureAwait(false); + return; } var response = context.HttpContext.Response; if (range is not null) { - return SendFileAsync( + await SendFileAsync( result.FileName, response, offset: range.From ?? 0L, - count: rangeLength); + count: rangeLength).ConfigureAwait(false); + return; } - return SendFileAsync( + await SendFileAsync( result.FileName, response, offset: 0, - count: null); + count: null).ConfigureAwait(false); } private async Task SendFileAsync(string filePath, HttpResponse response, long offset, long? count) |
