mirror of https://github.com/jellyfin/jellyfin.git
Make LibraryController.GetDownload async
This commit is contained in:
parent
ec3104d2d2
commit
fa8892fde4
|
@ -619,7 +619,7 @@ namespace Jellyfin.Api.Controllers
|
||||||
[Authorize(Policy = Policies.Download)]
|
[Authorize(Policy = Policies.Download)]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||||
public ActionResult GetDownload([FromRoute] Guid itemId)
|
public async Task<ActionResult> GetDownload([FromRoute] Guid itemId)
|
||||||
{
|
{
|
||||||
var item = _libraryManager.GetItemById(itemId);
|
var item = _libraryManager.GetItemById(itemId);
|
||||||
if (item == null)
|
if (item == null)
|
||||||
|
@ -648,7 +648,7 @@ namespace Jellyfin.Api.Controllers
|
||||||
|
|
||||||
if (user != null)
|
if (user != null)
|
||||||
{
|
{
|
||||||
LogDownload(item, user, auth);
|
await LogDownloadAsync(item, user, auth).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
var path = item.Path;
|
var path = item.Path;
|
||||||
|
@ -861,17 +861,17 @@ namespace Jellyfin.Api.Controllers
|
||||||
: item;
|
: item;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LogDownload(BaseItem item, User user, AuthorizationInfo auth)
|
private async Task LogDownloadAsync(BaseItem item, User user, AuthorizationInfo auth)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_activityManager.Create(new ActivityLog(
|
await _activityManager.CreateAsync(new ActivityLog(
|
||||||
string.Format(CultureInfo.InvariantCulture, _localization.GetLocalizedString("UserDownloadingItemWithValues"), user.Username, item.Name),
|
string.Format(CultureInfo.InvariantCulture, _localization.GetLocalizedString("UserDownloadingItemWithValues"), user.Username, item.Name),
|
||||||
"UserDownloadingContent",
|
"UserDownloadingContent",
|
||||||
auth.UserId)
|
auth.UserId)
|
||||||
{
|
{
|
||||||
ShortOverview = string.Format(CultureInfo.InvariantCulture, _localization.GetLocalizedString("AppDeviceValues"), auth.Client, auth.Device),
|
ShortOverview = string.Format(CultureInfo.InvariantCulture, _localization.GetLocalizedString("AppDeviceValues"), auth.Client, auth.Device),
|
||||||
});
|
}).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
|
|
|
@ -27,16 +27,6 @@ namespace Jellyfin.Server.Implementations.Activity
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public event EventHandler<GenericEventArgs<ActivityLogEntry>> EntryCreated;
|
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/>
|
/// <inheritdoc/>
|
||||||
public async Task CreateAsync(ActivityLog entry)
|
public async Task CreateAsync(ActivityLog entry)
|
||||||
{
|
{
|
||||||
|
|
|
@ -13,8 +13,6 @@ namespace MediaBrowser.Model.Activity
|
||||||
{
|
{
|
||||||
event EventHandler<GenericEventArgs<ActivityLogEntry>> EntryCreated;
|
event EventHandler<GenericEventArgs<ActivityLogEntry>> EntryCreated;
|
||||||
|
|
||||||
void Create(ActivityLog entry);
|
|
||||||
|
|
||||||
Task CreateAsync(ActivityLog entry);
|
Task CreateAsync(ActivityLog entry);
|
||||||
|
|
||||||
QueryResult<ActivityLogEntry> GetPagedResult(int? startIndex, int? limit);
|
QueryResult<ActivityLogEntry> GetPagedResult(int? startIndex, int? limit);
|
||||||
|
|
Loading…
Reference in New Issue