aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Providers/Plugins
diff options
context:
space:
mode:
authorBond_009 <bond.009@outlook.com>2024-10-31 17:02:06 +0100
committerBond_009 <bond.009@outlook.com>2024-10-31 17:02:06 +0100
commitd2db7004024c6bbdd541a381c673f1e0b0aebfcb (patch)
tree48d21b619b13c73fc85988d7c0b33a816b4f2c02 /MediaBrowser.Providers/Plugins
parent282784cbb6fe203b87a6f2c673454ac8d3da82fa (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 'MediaBrowser.Providers/Plugins')
-rw-r--r--MediaBrowser.Providers/Plugins/AudioDb/AudioDbAlbumProvider.cs12
-rw-r--r--MediaBrowser.Providers/Plugins/AudioDb/AudioDbArtistProvider.cs6
-rw-r--r--MediaBrowser.Providers/Plugins/StudioImages/StudiosImageProvider.cs4
3 files changed, 10 insertions, 12 deletions
diff --git a/MediaBrowser.Providers/Plugins/AudioDb/AudioDbAlbumProvider.cs b/MediaBrowser.Providers/Plugins/AudioDb/AudioDbAlbumProvider.cs
index daad9706c..ff30af879 100644
--- a/MediaBrowser.Providers/Plugins/AudioDb/AudioDbAlbumProvider.cs
+++ b/MediaBrowser.Providers/Plugins/AudioDb/AudioDbAlbumProvider.cs
@@ -148,21 +148,19 @@ namespace MediaBrowser.Providers.Plugins.AudioDb
item.Overview = (overview ?? string.Empty).StripHtml();
}
- internal Task EnsureInfo(string musicBrainzReleaseGroupId, CancellationToken cancellationToken)
+ internal async Task EnsureInfo(string musicBrainzReleaseGroupId, CancellationToken cancellationToken)
{
var xmlPath = GetAlbumInfoPath(_config.ApplicationPaths, musicBrainzReleaseGroupId);
var fileInfo = _fileSystem.GetFileSystemInfo(xmlPath);
- if (fileInfo.Exists)
+ if (fileInfo.Exists
+ && (DateTime.UtcNow - _fileSystem.GetLastWriteTimeUtc(fileInfo)).TotalDays <= 2)
{
- if ((DateTime.UtcNow - _fileSystem.GetLastWriteTimeUtc(fileInfo)).TotalDays <= 2)
- {
- return Task.CompletedTask;
- }
+ return;
}
- return DownloadInfo(musicBrainzReleaseGroupId, cancellationToken);
+ await DownloadInfo(musicBrainzReleaseGroupId, cancellationToken).ConfigureAwait(false);
}
internal async Task DownloadInfo(string musicBrainzReleaseGroupId, CancellationToken cancellationToken)
diff --git a/MediaBrowser.Providers/Plugins/AudioDb/AudioDbArtistProvider.cs b/MediaBrowser.Providers/Plugins/AudioDb/AudioDbArtistProvider.cs
index 92742b1aa..00bd96282 100644
--- a/MediaBrowser.Providers/Plugins/AudioDb/AudioDbArtistProvider.cs
+++ b/MediaBrowser.Providers/Plugins/AudioDb/AudioDbArtistProvider.cs
@@ -131,7 +131,7 @@ namespace MediaBrowser.Providers.Plugins.AudioDb
item.Overview = (overview ?? string.Empty).StripHtml();
}
- internal Task EnsureArtistInfo(string musicBrainzId, CancellationToken cancellationToken)
+ internal async Task EnsureArtistInfo(string musicBrainzId, CancellationToken cancellationToken)
{
var xmlPath = GetArtistInfoPath(_config.ApplicationPaths, musicBrainzId);
@@ -140,10 +140,10 @@ namespace MediaBrowser.Providers.Plugins.AudioDb
if (fileInfo.Exists
&& (DateTime.UtcNow - _fileSystem.GetLastWriteTimeUtc(fileInfo)).TotalDays <= 2)
{
- return Task.CompletedTask;
+ return;
}
- return DownloadArtistInfo(musicBrainzId, cancellationToken);
+ await DownloadArtistInfo(musicBrainzId, cancellationToken).ConfigureAwait(false);
}
internal async Task DownloadArtistInfo(string musicBrainzId, CancellationToken cancellationToken)
diff --git a/MediaBrowser.Providers/Plugins/StudioImages/StudiosImageProvider.cs b/MediaBrowser.Providers/Plugins/StudioImages/StudiosImageProvider.cs
index 5ca9f6f9a..a50d69df5 100644
--- a/MediaBrowser.Providers/Plugins/StudioImages/StudiosImageProvider.cs
+++ b/MediaBrowser.Providers/Plugins/StudioImages/StudiosImageProvider.cs
@@ -101,11 +101,11 @@ namespace MediaBrowser.Providers.Plugins.StudioImages
return string.Format(CultureInfo.InvariantCulture, "{0}/images/{1}/{2}.jpg", GetRepositoryUrl(), image, filename);
}
- private Task EnsureThumbsList(string file, CancellationToken cancellationToken)
+ private async Task EnsureThumbsList(string file, CancellationToken cancellationToken)
{
string url = string.Format(CultureInfo.InvariantCulture, "{0}/thumbs.txt", GetRepositoryUrl());
- return EnsureList(url, file, _fileSystem, cancellationToken);
+ await EnsureList(url, file, _fileSystem, cancellationToken).ConfigureAwait(false);
}
/// <inheritdoc />