diff options
| author | Patrick Barron <barronpm@gmail.com> | 2020-08-24 20:27:10 -0400 |
|---|---|---|
| committer | Patrick Barron <barronpm@gmail.com> | 2020-08-24 20:27:10 -0400 |
| commit | fa8892fde4282906f4522f033aa88e15b4397a03 (patch) | |
| tree | f109aa90c106e5cdb69be85b5948459e5dae4ff2 | |
| parent | ec3104d2d2654c47dbf41171ab218f78ddbaed23 (diff) | |
Make LibraryController.GetDownload async
| -rw-r--r-- | Jellyfin.Api/Controllers/LibraryController.cs | 10 | ||||
| -rw-r--r-- | Jellyfin.Server.Implementations/Activity/ActivityManager.cs | 10 | ||||
| -rw-r--r-- | MediaBrowser.Model/Activity/IActivityManager.cs | 2 |
3 files changed, 5 insertions, 17 deletions
diff --git a/Jellyfin.Api/Controllers/LibraryController.cs b/Jellyfin.Api/Controllers/LibraryController.cs index 4548e202a..796d2d8aa 100644 --- a/Jellyfin.Api/Controllers/LibraryController.cs +++ b/Jellyfin.Api/Controllers/LibraryController.cs @@ -619,7 +619,7 @@ namespace Jellyfin.Api.Controllers [Authorize(Policy = Policies.Download)] [ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status404NotFound)] - public ActionResult GetDownload([FromRoute] Guid itemId) + public async Task<ActionResult> GetDownload([FromRoute] Guid itemId) { var item = _libraryManager.GetItemById(itemId); if (item == null) @@ -648,7 +648,7 @@ namespace Jellyfin.Api.Controllers if (user != null) { - LogDownload(item, user, auth); + await LogDownloadAsync(item, user, auth).ConfigureAwait(false); } var path = item.Path; @@ -861,17 +861,17 @@ namespace Jellyfin.Api.Controllers : item; } - private void LogDownload(BaseItem item, User user, AuthorizationInfo auth) + private async Task LogDownloadAsync(BaseItem item, User user, AuthorizationInfo auth) { try { - _activityManager.Create(new ActivityLog( + await _activityManager.CreateAsync(new ActivityLog( string.Format(CultureInfo.InvariantCulture, _localization.GetLocalizedString("UserDownloadingItemWithValues"), user.Username, item.Name), "UserDownloadingContent", auth.UserId) { ShortOverview = string.Format(CultureInfo.InvariantCulture, _localization.GetLocalizedString("AppDeviceValues"), auth.Client, auth.Device), - }); + }).ConfigureAwait(false); } catch { diff --git a/Jellyfin.Server.Implementations/Activity/ActivityManager.cs b/Jellyfin.Server.Implementations/Activity/ActivityManager.cs index 2deefbe81..bd285f6f1 100644 --- a/Jellyfin.Server.Implementations/Activity/ActivityManager.cs +++ b/Jellyfin.Server.Implementations/Activity/ActivityManager.cs @@ -28,16 +28,6 @@ namespace Jellyfin.Server.Implementations.Activity public event EventHandler<GenericEventArgs<ActivityLogEntry>> EntryCreated; /// <inheritdoc/> - public void Create(ActivityLog entry) - { - using var dbContext = _provider.CreateContext(); - dbContext.ActivityLogs.Add(entry); - dbContext.SaveChanges(); - - EntryCreated?.Invoke(this, new GenericEventArgs<ActivityLogEntry>(ConvertToOldModel(entry))); - } - - /// <inheritdoc/> public async Task CreateAsync(ActivityLog entry) { await using var dbContext = _provider.CreateContext(); diff --git a/MediaBrowser.Model/Activity/IActivityManager.cs b/MediaBrowser.Model/Activity/IActivityManager.cs index 9dab5e77b..e5e7b0763 100644 --- a/MediaBrowser.Model/Activity/IActivityManager.cs +++ b/MediaBrowser.Model/Activity/IActivityManager.cs @@ -13,8 +13,6 @@ namespace MediaBrowser.Model.Activity { event EventHandler<GenericEventArgs<ActivityLogEntry>> EntryCreated; - void Create(ActivityLog entry); - Task CreateAsync(ActivityLog entry); QueryResult<ActivityLogEntry> GetPagedResult(int? startIndex, int? limit); |
