remove async when there's nothing to await

This commit is contained in:
Luke Pulverenti 2017-08-26 20:32:33 -04:00
parent 749a181fac
commit e287e3a50d
54 changed files with 287 additions and 348 deletions

View File

@ -128,7 +128,7 @@ namespace Emby.Server.Implementations.Activity
{
// Don't report theme song or local trailer playback
return;
}
}
if (e.Users.Count == 0)
{
@ -160,8 +160,8 @@ namespace Emby.Server.Implementations.Activity
{
// Don't report theme song or local trailer playback
return;
}
}
if (e.Users.Count == 0)
{
return;
@ -416,7 +416,7 @@ namespace Emby.Server.Implementations.Activity
{
return;
}
var time = result.EndTimeUtc - result.StartTimeUtc;
var runningTime = string.Format(_localization.GetLocalizedString("LabelRunningTimeValue"), ToUserFriendlyString(time));
@ -444,11 +444,11 @@ namespace Emby.Server.Implementations.Activity
}
}
private async void CreateLogEntry(ActivityLogEntry entry)
private void CreateLogEntry(ActivityLogEntry entry)
{
try
{
await _activityManager.Create(entry).ConfigureAwait(false);
_activityManager.Create(entry);
}
catch
{

View File

@ -13,7 +13,7 @@ namespace Emby.Server.Implementations.Activity
public class ActivityManager : IActivityManager
{
public event EventHandler<GenericEventArgs<ActivityLogEntry>> EntryCreated;
private readonly IActivityRepository _repo;
private readonly ILogger _logger;
private readonly IUserManager _userManager;
@ -25,12 +25,12 @@ namespace Emby.Server.Implementations.Activity
_userManager = userManager;
}
public async Task Create(ActivityLogEntry entry)
public void Create(ActivityLogEntry entry)
{
entry.Id = Guid.NewGuid().ToString("N");
entry.Date = DateTime.UtcNow;
await _repo.Create(entry).ConfigureAwait(false);
_repo.Create(entry);
EventHelper.FireEventIfNotNull(EntryCreated, this, new GenericEventArgs<ActivityLogEntry>(entry), _logger);
}

View File

@ -3,7 +3,6 @@ using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Emby.Server.Implementations.Data;
using MediaBrowser.Controller;
using MediaBrowser.Model.Activity;
@ -41,12 +40,12 @@ namespace Emby.Server.Implementations.Activity
private const string BaseActivitySelectText = "select Id, Name, Overview, ShortOverview, Type, ItemId, UserId, DateCreated, LogSeverity from ActivityLogEntries";
public Task Create(ActivityLogEntry entry)
public void Create(ActivityLogEntry entry)
{
return Update(entry);
Update(entry);
}
public async Task Update(ActivityLogEntry entry)
public void Update(ActivityLogEntry entry)
{
if (entry == null)
{

View File

@ -1048,7 +1048,7 @@ namespace Emby.Server.Implementations
SetStaticProperties();
await ((UserManager)UserManager).Initialize().ConfigureAwait(false);
((UserManager)UserManager).Initialize();
}
protected virtual string PackageRuntime

View File

@ -429,7 +429,7 @@ namespace Emby.Server.Implementations.Channels
if (isNew)
{
await _libraryManager.CreateItem(item, cancellationToken).ConfigureAwait(false);
_libraryManager.CreateItem(item, cancellationToken);
}
else if (forceUpdate)
{
@ -1388,11 +1388,11 @@ namespace Emby.Server.Implementations.Channels
if (isNew)
{
await _libraryManager.CreateItem(item, cancellationToken).ConfigureAwait(false);
_libraryManager.CreateItem(item, cancellationToken);
if (info.People != null && info.People.Count > 0)
{
await _libraryManager.UpdatePeople(item, info.People ?? new List<PersonInfo>()).ConfigureAwait(false);
_libraryManager.UpdatePeople(item, info.People ?? new List<PersonInfo>());
}
}
else if (forceUpdate)

View File

@ -90,7 +90,7 @@ namespace Emby.Server.Implementations.Collections
}).ToList()
};
await parentFolder.AddChild(collection, CancellationToken.None).ConfigureAwait(false);
parentFolder.AddChild(collection, CancellationToken.None);
if (options.ItemIdList.Length > 0)
{

View File

@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
using MediaBrowser.Common.Configuration;
using MediaBrowser.Common.Extensions;
using MediaBrowser.Controller.Persistence;
@ -75,7 +74,7 @@ namespace Emby.Server.Implementations.Data
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Task.</returns>
/// <exception cref="System.ArgumentNullException">item</exception>
public async Task SaveDisplayPreferences(DisplayPreferences displayPreferences, Guid userId, string client, CancellationToken cancellationToken)
public void SaveDisplayPreferences(DisplayPreferences displayPreferences, Guid userId, string client, CancellationToken cancellationToken)
{
if (displayPreferences == null)
{
@ -123,7 +122,7 @@ namespace Emby.Server.Implementations.Data
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Task.</returns>
/// <exception cref="System.ArgumentNullException">item</exception>
public async Task SaveAllDisplayPreferences(IEnumerable<DisplayPreferences> displayPreferences, Guid userId, CancellationToken cancellationToken)
public void SaveAllDisplayPreferences(IEnumerable<DisplayPreferences> displayPreferences, Guid userId, CancellationToken cancellationToken)
{
if (displayPreferences == null)
{
@ -226,9 +225,9 @@ namespace Emby.Server.Implementations.Data
}
}
public Task SaveDisplayPreferences(DisplayPreferences displayPreferences, string userId, string client, CancellationToken cancellationToken)
public void SaveDisplayPreferences(DisplayPreferences displayPreferences, string userId, string client, CancellationToken cancellationToken)
{
return SaveDisplayPreferences(displayPreferences, new Guid(userId), client, cancellationToken);
SaveDisplayPreferences(displayPreferences, new Guid(userId), client, cancellationToken);
}
public DisplayPreferences GetDisplayPreferences(string displayPreferencesId, string userId, string client)

View File

@ -132,8 +132,7 @@ namespace Emby.Server.Implementations.Data
/// <summary>
/// Opens the connection to the database
/// </summary>
/// <returns>Task.</returns>
public async Task Initialize(SqliteUserDataRepository userDataRepo)
public void Initialize(SqliteUserDataRepository userDataRepo)
{
using (var connection = CreateConnection())
{
@ -600,16 +599,15 @@ namespace Emby.Server.Implementations.Data
/// </summary>
/// <param name="item">The item.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Task.</returns>
/// <exception cref="System.ArgumentNullException">item</exception>
public Task SaveItem(BaseItem item, CancellationToken cancellationToken)
public void SaveItem(BaseItem item, CancellationToken cancellationToken)
{
if (item == null)
{
throw new ArgumentNullException("item");
}
return SaveItems(new List<BaseItem> { item }, cancellationToken);
SaveItems(new List<BaseItem> { item }, cancellationToken);
}
/// <summary>
@ -617,13 +615,12 @@ namespace Emby.Server.Implementations.Data
/// </summary>
/// <param name="items">The items.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Task.</returns>
/// <exception cref="System.ArgumentNullException">
/// items
/// or
/// cancellationToken
/// </exception>
public async Task SaveItems(List<BaseItem> items, CancellationToken cancellationToken)
public void SaveItems(List<BaseItem> items, CancellationToken cancellationToken)
{
if (items == null)
{
@ -1959,22 +1956,18 @@ namespace Emby.Server.Implementations.Data
/// Gets the critic reviews.
/// </summary>
/// <param name="itemId">The item id.</param>
/// <returns>Task{IEnumerable{ItemReview}}.</returns>
public List<ItemReview> GetCriticReviews(Guid itemId)
{
return new List<ItemReview>();
}
private readonly Task _cachedTask = Task.FromResult(true);
/// <summary>
/// Saves the critic reviews.
/// </summary>
/// <param name="itemId">The item id.</param>
/// <param name="criticReviews">The critic reviews.</param>
/// <returns>Task.</returns>
public Task SaveCriticReviews(Guid itemId, IEnumerable<ItemReview> criticReviews)
public void SaveCriticReviews(Guid itemId, IEnumerable<ItemReview> criticReviews)
{
return _cachedTask;
}
/// <summary>
@ -2079,7 +2072,7 @@ namespace Emby.Server.Implementations.Data
/// <summary>
/// Saves the chapters.
/// </summary>
public async Task SaveChapters(Guid id, List<ChapterInfo> chapters)
public void SaveChapters(Guid id, List<ChapterInfo> chapters)
{
CheckDisposed();
@ -4654,12 +4647,12 @@ namespace Emby.Server.Implementations.Data
typeof(AggregateFolder)
};
public async Task UpdateInheritedValues(CancellationToken cancellationToken)
public void UpdateInheritedValues(CancellationToken cancellationToken)
{
await UpdateInheritedTags(cancellationToken).ConfigureAwait(false);
UpdateInheritedTags(cancellationToken);
}
private async Task UpdateInheritedTags(CancellationToken cancellationToken)
private void UpdateInheritedTags(CancellationToken cancellationToken)
{
var newValues = new List<Tuple<Guid, string[]>>();
@ -4754,7 +4747,7 @@ limit 100";
return new[] { value }.Where(IsValidType);
}
public async Task DeleteItem(Guid id, CancellationToken cancellationToken)
public void DeleteItem(Guid id, CancellationToken cancellationToken)
{
if (id == Guid.Empty)
{
@ -5485,7 +5478,7 @@ limit 100";
}
}
public async Task UpdatePeople(Guid itemId, List<PersonInfo> people)
public void UpdatePeople(Guid itemId, List<PersonInfo> people)
{
if (itemId == Guid.Empty)
{
@ -5615,7 +5608,7 @@ limit 100";
}
}
public async Task SaveMediaStreams(Guid id, List<MediaStream> streams, CancellationToken cancellationToken)
public void SaveMediaStreams(Guid id, List<MediaStream> streams, CancellationToken cancellationToken)
{
CheckDisposed();

View File

@ -3,7 +3,6 @@ using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using MediaBrowser.Common.Configuration;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Persistence;
@ -153,7 +152,7 @@ namespace Emby.Server.Implementations.Data
/// userId
/// or
/// userDataId</exception>
public Task SaveUserData(Guid userId, string key, UserItemData userData, CancellationToken cancellationToken)
public void SaveUserData(Guid userId, string key, UserItemData userData, CancellationToken cancellationToken)
{
if (userData == null)
{
@ -168,10 +167,10 @@ namespace Emby.Server.Implementations.Data
throw new ArgumentNullException("key");
}
return PersistUserData(userId, key, userData, cancellationToken);
PersistUserData(userId, key, userData, cancellationToken);
}
public Task SaveAllUserData(Guid userId, IEnumerable<UserItemData> userData, CancellationToken cancellationToken)
public void SaveAllUserData(Guid userId, UserItemData[] userData, CancellationToken cancellationToken)
{
if (userData == null)
{
@ -182,7 +181,7 @@ namespace Emby.Server.Implementations.Data
throw new ArgumentNullException("userId");
}
return PersistAllUserData(userId, userData.ToList(), cancellationToken);
PersistAllUserData(userId, userData, cancellationToken);
}
/// <summary>
@ -193,7 +192,7 @@ namespace Emby.Server.Implementations.Data
/// <param name="userData">The user data.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Task.</returns>
public async Task PersistUserData(Guid userId, string key, UserItemData userData, CancellationToken cancellationToken)
public void PersistUserData(Guid userId, string key, UserItemData userData, CancellationToken cancellationToken)
{
cancellationToken.ThrowIfCancellationRequested();
@ -264,7 +263,7 @@ namespace Emby.Server.Implementations.Data
/// <summary>
/// Persist all user data for the specified user
/// </summary>
private async Task PersistAllUserData(Guid userId, List<UserItemData> userDataList, CancellationToken cancellationToken)
private void PersistAllUserData(Guid userId, UserItemData[] userDataList, CancellationToken cancellationToken)
{
cancellationToken.ThrowIfCancellationRequested();
@ -349,7 +348,7 @@ namespace Emby.Server.Implementations.Data
/// </summary>
/// <param name="userId"></param>
/// <returns></returns>
public IEnumerable<UserItemData> GetAllUserData(Guid userId)
public List<UserItemData> GetAllUserData(Guid userId)
{
if (userId == Guid.Empty)
{

View File

@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
using MediaBrowser.Controller;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Persistence;
@ -72,7 +71,7 @@ namespace Emby.Server.Implementations.Data
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Task.</returns>
/// <exception cref="System.ArgumentNullException">user</exception>
public async Task SaveUser(User user, CancellationToken cancellationToken)
public void SaveUser(User user, CancellationToken cancellationToken)
{
if (user == null)
{
@ -139,7 +138,7 @@ namespace Emby.Server.Implementations.Data
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Task.</returns>
/// <exception cref="System.ArgumentNullException">user</exception>
public async Task DeleteUser(User user, CancellationToken cancellationToken)
public void DeleteUser(User user, CancellationToken cancellationToken)
{
if (user == null)
{

View File

@ -461,10 +461,10 @@ namespace Emby.Server.Implementations.Library
parent.RemoveChild(item);
}
await ItemRepository.DeleteItem(item.Id, CancellationToken.None).ConfigureAwait(false);
ItemRepository.DeleteItem(item.Id, CancellationToken.None);
foreach (var child in children)
{
await ItemRepository.DeleteItem(child.Id, CancellationToken.None).ConfigureAwait(false);
ItemRepository.DeleteItem(child.Id, CancellationToken.None);
}
BaseItem removed;
@ -997,8 +997,7 @@ namespace Emby.Server.Implementations.Library
Path = path
};
var task = CreateItem(item, CancellationToken.None);
Task.WaitAll(task);
CreateItem(item, CancellationToken.None);
}
return item;
@ -1170,7 +1169,7 @@ namespace Emby.Server.Implementations.Library
progress.Report(percent * 100);
}
await ItemRepository.UpdateInheritedValues(cancellationToken).ConfigureAwait(false);
ItemRepository.UpdateInheritedValues(cancellationToken);
progress.Report(100);
}
@ -1812,9 +1811,9 @@ namespace Emby.Server.Implementations.Library
/// <param name="item">The item.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Task.</returns>
public Task CreateItem(BaseItem item, CancellationToken cancellationToken)
public void CreateItem(BaseItem item, CancellationToken cancellationToken)
{
return CreateItems(new[] { item }, cancellationToken);
CreateItems(new[] { item }, cancellationToken);
}
/// <summary>
@ -1823,11 +1822,11 @@ namespace Emby.Server.Implementations.Library
/// <param name="items">The items.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Task.</returns>
public async Task CreateItems(IEnumerable<BaseItem> items, CancellationToken cancellationToken)
public void CreateItems(IEnumerable<BaseItem> items, CancellationToken cancellationToken)
{
var list = items.ToList();
await ItemRepository.SaveItems(list, cancellationToken).ConfigureAwait(false);
ItemRepository.SaveItems(list, cancellationToken);
foreach (var item in list)
{
@ -1870,7 +1869,7 @@ namespace Emby.Server.Implementations.Library
var logName = item.LocationType == LocationType.Remote ? item.Name ?? item.Path : item.Path ?? item.Name;
_logger.Debug("Saving {0} to database.", logName);
await ItemRepository.SaveItem(item, cancellationToken).ConfigureAwait(false);
ItemRepository.SaveItem(item, cancellationToken);
RegisterItem(item);
@ -2067,7 +2066,7 @@ namespace Emby.Server.Implementations.Library
private readonly TimeSpan _viewRefreshInterval = TimeSpan.FromHours(24);
//private readonly TimeSpan _viewRefreshInterval = TimeSpan.FromMinutes(1);
public Task<UserView> GetNamedView(User user,
public UserView GetNamedView(User user,
string name,
string viewType,
string sortName,
@ -2105,7 +2104,7 @@ namespace Emby.Server.Implementations.Library
ForcedSortName = sortName
};
await CreateItem(item, cancellationToken).ConfigureAwait(false);
CreateItem(item, cancellationToken);
refresh = true;
}
@ -2136,7 +2135,7 @@ namespace Emby.Server.Implementations.Library
return item;
}
public async Task<UserView> GetNamedView(User user,
public UserView GetNamedView(User user,
string name,
string parentId,
string viewType,
@ -2173,7 +2172,7 @@ namespace Emby.Server.Implementations.Library
item.DisplayParentId = new Guid(parentId);
}
await CreateItem(item, cancellationToken).ConfigureAwait(false);
CreateItem(item, cancellationToken);
isNew = true;
}
@ -2199,7 +2198,7 @@ namespace Emby.Server.Implementations.Library
return item;
}
public async Task<UserView> GetShadowView(BaseItem parent,
public UserView GetShadowView(BaseItem parent,
string viewType,
string sortName,
CancellationToken cancellationToken)
@ -2238,7 +2237,7 @@ namespace Emby.Server.Implementations.Library
item.DisplayParentId = parentId;
await CreateItem(item, cancellationToken).ConfigureAwait(false);
CreateItem(item, cancellationToken);
isNew = true;
}
@ -2309,7 +2308,7 @@ namespace Emby.Server.Implementations.Library
item.DisplayParentId = new Guid(parentId);
}
await CreateItem(item, cancellationToken).ConfigureAwait(false);
CreateItem(item, cancellationToken);
isNew = true;
}
@ -2823,14 +2822,14 @@ namespace Emby.Server.Implementations.Library
return ItemRepository.GetPeopleNames(query);
}
public Task UpdatePeople(BaseItem item, List<PersonInfo> people)
public void UpdatePeople(BaseItem item, List<PersonInfo> people)
{
if (!item.SupportsPeople)
{
return Task.FromResult(true);
return;
}
return ItemRepository.UpdatePeople(item.Id, people);
ItemRepository.UpdatePeople(item.Id, people);
}
public async Task<ItemImageInfo> ConvertImageToLocal(IHasMetadata item, ItemImageInfo image, int imageIndex)

View File

@ -41,7 +41,7 @@ namespace Emby.Server.Implementations.Library
/// <value>The repository.</value>
public IUserDataRepository Repository { get; set; }
public async Task SaveUserData(Guid userId, IHasUserData item, UserItemData userData, UserDataSaveReason reason, CancellationToken cancellationToken)
public void SaveUserData(Guid userId, IHasUserData item, UserItemData userData, UserDataSaveReason reason, CancellationToken cancellationToken)
{
if (userData == null)
{
@ -62,7 +62,7 @@ namespace Emby.Server.Implementations.Library
foreach (var key in keys)
{
await Repository.SaveUserData(userId, key, userData, cancellationToken).ConfigureAwait(false);
Repository.SaveUserData(userId, key, userData, cancellationToken);
}
var cacheKey = GetCacheKey(userId, item.Id);
@ -86,7 +86,7 @@ namespace Emby.Server.Implementations.Library
/// <param name="userData"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public async Task SaveAllUserData(Guid userId, IEnumerable<UserItemData> userData, CancellationToken cancellationToken)
public void SaveAllUserData(Guid userId, UserItemData[] userData, CancellationToken cancellationToken)
{
if (userData == null)
{
@ -99,7 +99,7 @@ namespace Emby.Server.Implementations.Library
cancellationToken.ThrowIfCancellationRequested();
await Repository.SaveAllUserData(userId, userData, cancellationToken).ConfigureAwait(false);
Repository.SaveAllUserData(userId, userData, cancellationToken);
}
/// <summary>
@ -107,7 +107,7 @@ namespace Emby.Server.Implementations.Library
/// </summary>
/// <param name="userId"></param>
/// <returns></returns>
public IEnumerable<UserItemData> GetAllUserData(Guid userId)
public List<UserItemData> GetAllUserData(Guid userId)
{
if (userId == Guid.Empty)
{
@ -187,7 +187,7 @@ namespace Emby.Server.Implementations.Library
var userData = GetUserData(user.Id, item);
var dto = GetUserItemDataDto(userData);
item.FillUserDataDtoValues(dto, userData, null, user, new ItemFields[]{});
item.FillUserDataDtoValues(dto, userData, null, user, new ItemFields[] { });
return dto;
}

View File

@ -160,9 +160,9 @@ namespace Emby.Server.Implementations.Library
return Users.FirstOrDefault(u => string.Equals(u.Name, name, StringComparison.OrdinalIgnoreCase));
}
public async Task Initialize()
public void Initialize()
{
Users = await LoadUsers().ConfigureAwait(false);
Users = LoadUsers();
var users = Users.ToList();
@ -174,7 +174,7 @@ namespace Emby.Server.Implementations.Library
if (!user.ConnectLinkType.HasValue || user.ConnectLinkType.Value == UserLinkType.LinkedUser)
{
user.Policy.IsAdministrator = true;
await UpdateUserPolicy(user, user.Policy, false).ConfigureAwait(false);
UpdateUserPolicy(user, user.Policy, false);
}
}
}
@ -294,12 +294,12 @@ namespace Emby.Server.Implementations.Library
if (success)
{
user.LastActivityDate = user.LastLoginDate = DateTime.UtcNow;
await UpdateUser(user).ConfigureAwait(false);
await UpdateInvalidLoginAttemptCount(user, 0).ConfigureAwait(false);
UpdateUser(user);
UpdateInvalidLoginAttemptCount(user, 0);
}
else
{
await UpdateInvalidLoginAttemptCount(user, user.Policy.InvalidLoginAttemptCount + 1).ConfigureAwait(false);
UpdateInvalidLoginAttemptCount(user, user.Policy.InvalidLoginAttemptCount + 1);
}
_logger.Info("Authentication request for {0} {1}.", user.Name, success ? "has succeeded" : "has been denied");
@ -307,7 +307,7 @@ namespace Emby.Server.Implementations.Library
return success ? user : null;
}
private async Task UpdateInvalidLoginAttemptCount(User user, int newValue)
private void UpdateInvalidLoginAttemptCount(User user, int newValue)
{
if (user.Policy.InvalidLoginAttemptCount != newValue || newValue > 0)
{
@ -327,7 +327,7 @@ namespace Emby.Server.Implementations.Library
//fireLockout = true;
}
await UpdateUserPolicy(user, user.Policy, false).ConfigureAwait(false);
UpdateUserPolicy(user, user.Policy, false);
if (fireLockout)
{
@ -372,7 +372,7 @@ namespace Emby.Server.Implementations.Library
/// Loads the users from the repository
/// </summary>
/// <returns>IEnumerable{User}.</returns>
private async Task<IEnumerable<User>> LoadUsers()
private List<User> LoadUsers()
{
var users = UserRepository.RetrieveAllUsers().ToList();
@ -385,14 +385,14 @@ namespace Emby.Server.Implementations.Library
user.DateLastSaved = DateTime.UtcNow;
await UserRepository.SaveUser(user, CancellationToken.None).ConfigureAwait(false);
UserRepository.SaveUser(user, CancellationToken.None);
users.Add(user);
user.Policy.IsAdministrator = true;
user.Policy.EnableContentDeletion = true;
user.Policy.EnableRemoteControlOfOtherUsers = true;
await UpdateUserPolicy(user, user.Policy, false).ConfigureAwait(false);
UpdateUserPolicy(user, user.Policy, false);
}
return users;
@ -539,7 +539,7 @@ namespace Emby.Server.Implementations.Library
/// <param name="user">The user.</param>
/// <exception cref="System.ArgumentNullException">user</exception>
/// <exception cref="System.ArgumentException"></exception>
public async Task UpdateUser(User user)
public void UpdateUser(User user)
{
if (user == null)
{
@ -554,7 +554,7 @@ namespace Emby.Server.Implementations.Library
user.DateModified = DateTime.UtcNow;
user.DateLastSaved = DateTime.UtcNow;
await UserRepository.SaveUser(user, CancellationToken.None).ConfigureAwait(false);
UserRepository.SaveUser(user, CancellationToken.None);
OnUserUpdated(user);
}
@ -599,7 +599,7 @@ namespace Emby.Server.Implementations.Library
user.DateLastSaved = DateTime.UtcNow;
await UserRepository.SaveUser(user, CancellationToken.None).ConfigureAwait(false);
UserRepository.SaveUser(user, CancellationToken.None);
EventHelper.QueueEventIfNotNull(UserCreated, this, new GenericEventArgs<User> { Argument = user }, _logger);
@ -653,7 +653,7 @@ namespace Emby.Server.Implementations.Library
{
var configPath = GetConfigurationFilePath(user);
await UserRepository.DeleteUser(user, CancellationToken.None).ConfigureAwait(false);
UserRepository.DeleteUser(user, CancellationToken.None);
try
{
@ -667,7 +667,7 @@ namespace Emby.Server.Implementations.Library
DeleteUserPolicy(user);
// Force this to be lazy loaded again
Users = await LoadUsers().ConfigureAwait(false);
Users = LoadUsers();
OnUserDeleted(user);
}
@ -681,17 +681,17 @@ namespace Emby.Server.Implementations.Library
/// Resets the password by clearing it.
/// </summary>
/// <returns>Task.</returns>
public Task ResetPassword(User user)
public void ResetPassword(User user)
{
return ChangePassword(user, GetSha1String(string.Empty));
ChangePassword(user, GetSha1String(string.Empty));
}
public Task ResetEasyPassword(User user)
public void ResetEasyPassword(User user)
{
return ChangeEasyPassword(user, GetSha1String(string.Empty));
ChangeEasyPassword(user, GetSha1String(string.Empty));
}
public async Task ChangePassword(User user, string newPasswordSha1)
public void ChangePassword(User user, string newPasswordSha1)
{
if (user == null)
{
@ -709,12 +709,12 @@ namespace Emby.Server.Implementations.Library
user.Password = newPasswordSha1;
await UpdateUser(user).ConfigureAwait(false);
UpdateUser(user);
EventHelper.FireEventIfNotNull(UserPasswordChanged, this, new GenericEventArgs<User>(user), _logger);
}
public async Task ChangeEasyPassword(User user, string newPasswordSha1)
public void ChangeEasyPassword(User user, string newPasswordSha1)
{
if (user == null)
{
@ -727,7 +727,7 @@ namespace Emby.Server.Implementations.Library
user.EasyPassword = newPasswordSha1;
await UpdateUser(user).ConfigureAwait(false);
UpdateUser(user);
EventHelper.FireEventIfNotNull(UserPasswordChanged, this, new GenericEventArgs<User>(user), _logger);
}
@ -842,7 +842,7 @@ namespace Emby.Server.Implementations.Library
};
}
public async Task<PinRedeemResult> RedeemPasswordResetPin(string pin)
public PinRedeemResult RedeemPasswordResetPin(string pin)
{
DeletePinFile();
@ -863,12 +863,12 @@ namespace Emby.Server.Implementations.Library
foreach (var user in users)
{
await ResetPassword(user).ConfigureAwait(false);
ResetPassword(user);
if (user.Policy.IsDisabled)
{
user.Policy.IsDisabled = false;
await UpdateUserPolicy(user, user.Policy, true).ConfigureAwait(false);
UpdateUserPolicy(user, user.Policy, true);
}
usersReset.Add(user.Name);
}
@ -945,13 +945,13 @@ namespace Emby.Server.Implementations.Library
}
private readonly object _policySyncLock = new object();
public Task UpdateUserPolicy(string userId, UserPolicy userPolicy)
public void UpdateUserPolicy(string userId, UserPolicy userPolicy)
{
var user = GetUserById(userId);
return UpdateUserPolicy(user, userPolicy, true);
UpdateUserPolicy(user, userPolicy, true);
}
private async Task UpdateUserPolicy(User user, UserPolicy userPolicy, bool fireEvent)
private void UpdateUserPolicy(User user, UserPolicy userPolicy, bool fireEvent)
{
// The xml serializer will output differently if the type is not exact
if (userPolicy.GetType() != typeof(UserPolicy))
@ -970,7 +970,7 @@ namespace Emby.Server.Implementations.Library
user.Policy = userPolicy;
}
await UpdateConfiguration(user, user.Configuration, true).ConfigureAwait(false);
UpdateConfiguration(user, user.Configuration, true);
}
private void DeleteUserPolicy(User user)
@ -1032,13 +1032,13 @@ namespace Emby.Server.Implementations.Library
}
private readonly object _configSyncLock = new object();
public Task UpdateConfiguration(string userId, UserConfiguration config)
public void UpdateConfiguration(string userId, UserConfiguration config)
{
var user = GetUserById(userId);
return UpdateConfiguration(user, config, true);
UpdateConfiguration(user, config, true);
}
private async Task UpdateConfiguration(User user, UserConfiguration config, bool fireEvent)
private void UpdateConfiguration(User user, UserConfiguration config, bool fireEvent)
{
var path = GetConfigurationFilePath(user);

View File

@ -68,7 +68,7 @@ namespace Emby.Server.Implementations.Library
if (UserView.IsUserSpecific(folder))
{
list.Add(await _libraryManager.GetNamedView(user, folder.Name, folder.Id.ToString("N"), folderViewType, null, cancellationToken).ConfigureAwait(false));
list.Add(_libraryManager.GetNamedView(user, folder.Name, folder.Id.ToString("N"), folderViewType, null, cancellationToken));
continue;
}
@ -80,7 +80,7 @@ namespace Emby.Server.Implementations.Library
if (query.PresetViews.Contains(folderViewType ?? string.Empty, StringComparer.OrdinalIgnoreCase))
{
list.Add(await GetUserView(folder, folderViewType, string.Empty, cancellationToken).ConfigureAwait(false));
list.Add(GetUserView(folder, folderViewType, string.Empty, cancellationToken));
}
else
{
@ -95,7 +95,7 @@ namespace Emby.Server.Implementations.Library
if (parents.Count > 0)
{
list.Add(await GetUserView(parents, viewType, string.Empty, user, query.PresetViews, cancellationToken).ConfigureAwait(false));
list.Add(GetUserView(parents, viewType, string.Empty, user, query.PresetViews, cancellationToken));
}
}
@ -114,7 +114,7 @@ namespace Emby.Server.Implementations.Library
}, cancellationToken).ConfigureAwait(false);
var channels = channelResult.Items;
if (_config.Configuration.EnableChannelView && channels.Length > 0)
{
list.Add(await _channelManager.GetInternalChannelFolder(cancellationToken).ConfigureAwait(false));
@ -172,7 +172,7 @@ namespace Emby.Server.Implementations.Library
return GetUserSubView(name, parentId, type, sortName, cancellationToken);
}
private async Task<Folder> GetUserView(List<ICollectionFolder> parents, string viewType, string sortName, User user, string[] presetViews, CancellationToken cancellationToken)
private Folder GetUserView(List<ICollectionFolder> parents, string viewType, string sortName, User user, string[] presetViews, CancellationToken cancellationToken)
{
if (parents.Count == 1 && parents.All(i => string.Equals(i.CollectionType, viewType, StringComparison.OrdinalIgnoreCase)))
{
@ -181,14 +181,14 @@ namespace Emby.Server.Implementations.Library
return (Folder)parents[0];
}
return await GetUserView((Folder)parents[0], viewType, string.Empty, cancellationToken).ConfigureAwait(false);
return GetUserView((Folder)parents[0], viewType, string.Empty, cancellationToken);
}
var name = _localizationManager.GetLocalizedString("ViewType" + viewType);
return await _libraryManager.GetNamedView(user, name, viewType, sortName, cancellationToken).ConfigureAwait(false);
return _libraryManager.GetNamedView(user, name, viewType, sortName, cancellationToken);
}
public Task<UserView> GetUserView(Folder parent, string viewType, string sortName, CancellationToken cancellationToken)
public UserView GetUserView(Folder parent, string viewType, string sortName, CancellationToken cancellationToken)
{
return _libraryManager.GetShadowView(parent, viewType, sortName, cancellationToken);
}

View File

@ -558,7 +558,7 @@ namespace Emby.Server.Implementations.LiveTv
if (isNew)
{
await _libraryManager.CreateItem(item, cancellationToken).ConfigureAwait(false);
_libraryManager.CreateItem(item, cancellationToken);
}
else if (forceUpdate)
{
@ -875,7 +875,7 @@ namespace Emby.Server.Implementations.LiveTv
if (isNew)
{
await _libraryManager.CreateItem(item, cancellationToken).ConfigureAwait(false);
_libraryManager.CreateItem(item, cancellationToken);
}
else if (dataChanged || info.DateLastUpdated > recording.DateLastSaved || statusChanged)
{
@ -1410,7 +1410,7 @@ namespace Emby.Server.Implementations.LiveTv
if (newPrograms.Count > 0)
{
await _libraryManager.CreateItems(newPrograms, cancellationToken).ConfigureAwait(false);
_libraryManager.CreateItems(newPrograms, cancellationToken);
}
// TODO: Do this in bulk

View File

@ -179,7 +179,7 @@ namespace Emby.Server.Implementations.MediaEncoder
if (saveChapters && changesMade)
{
await _chapterManager.SaveChapters(video.Id.ToString(), chapters).ConfigureAwait(false);
_chapterManager.SaveChapters(video.Id.ToString(), chapters);
}
DeleteDeadImages(currentImages, chapters);

View File

@ -128,7 +128,7 @@ namespace Emby.Server.Implementations.Playlists
playlist.SetMediaType(options.MediaType);
await parentFolder.AddChild(playlist, CancellationToken.None).ConfigureAwait(false);
parentFolder.AddChild(playlist, CancellationToken.None);
await playlist.RefreshMetadata(new MetadataRefreshOptions(_fileSystem) { ForceSave = true }, CancellationToken.None)
.ConfigureAwait(false);

View File

@ -4,7 +4,6 @@ using System.Globalization;
using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Emby.Server.Implementations.Data;
using MediaBrowser.Controller;
using MediaBrowser.Controller.Security;
@ -51,14 +50,14 @@ namespace Emby.Server.Implementations.Security
}
}
public Task Create(AuthenticationInfo info, CancellationToken cancellationToken)
public void Create(AuthenticationInfo info, CancellationToken cancellationToken)
{
info.Id = Guid.NewGuid().ToString("N");
return Update(info, cancellationToken);
Update(info, cancellationToken);
}
public async Task Update(AuthenticationInfo info, CancellationToken cancellationToken)
public void Update(AuthenticationInfo info, CancellationToken cancellationToken)
{
if (info == null)
{

View File

@ -6,11 +6,8 @@ using MediaBrowser.Controller.Devices;
using MediaBrowser.Controller.Drawing;
using MediaBrowser.Controller.Dto;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.Audio;
using MediaBrowser.Controller.Entities.TV;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.LiveTv;
using MediaBrowser.Controller.Persistence;
using MediaBrowser.Controller.Security;
using MediaBrowser.Controller.Session;
using MediaBrowser.Model.Devices;
@ -253,7 +250,7 @@ namespace Emby.Server.Implementations.Session
{
try
{
await _userManager.UpdateUser(user).ConfigureAwait(false);
_userManager.UpdateUser(user);
}
catch (Exception ex)
{
@ -622,7 +619,7 @@ namespace Emby.Server.Implementations.Session
{
foreach (var user in users)
{
await OnPlaybackStart(user.Id, libraryItem).ConfigureAwait(false);
OnPlaybackStart(user.Id, libraryItem);
}
}
@ -650,8 +647,7 @@ namespace Emby.Server.Implementations.Session
/// </summary>
/// <param name="userId">The user identifier.</param>
/// <param name="item">The item.</param>
/// <returns>Task.</returns>
private async Task OnPlaybackStart(Guid userId, IHasUserData item)
private void OnPlaybackStart(Guid userId, IHasUserData item)
{
var data = _userDataManager.GetUserData(userId, item);
@ -670,7 +666,7 @@ namespace Emby.Server.Implementations.Session
data.Played = false;
}
await _userDataManager.SaveUserData(userId, item, data, UserDataSaveReason.PlaybackStart, CancellationToken.None).ConfigureAwait(false);
_userDataManager.SaveUserData(userId, item, data, UserDataSaveReason.PlaybackStart, CancellationToken.None);
}
public Task OnPlaybackProgress(PlaybackProgressInfo info)
@ -702,7 +698,7 @@ namespace Emby.Server.Implementations.Session
{
foreach (var user in users)
{
await OnPlaybackProgress(user, libraryItem, info).ConfigureAwait(false);
OnPlaybackProgress(user, libraryItem, info);
}
}
@ -730,7 +726,7 @@ namespace Emby.Server.Implementations.Session
StartIdleCheckTimer();
}
private async Task OnPlaybackProgress(User user, BaseItem item, PlaybackProgressInfo info)
private void OnPlaybackProgress(User user, BaseItem item, PlaybackProgressInfo info)
{
var data = _userDataManager.GetUserData(user.Id, item);
@ -742,7 +738,7 @@ namespace Emby.Server.Implementations.Session
UpdatePlaybackSettings(user, info, data);
await _userDataManager.SaveUserData(user.Id, item, data, UserDataSaveReason.PlaybackProgress, CancellationToken.None).ConfigureAwait(false);
_userDataManager.SaveUserData(user.Id, item, data, UserDataSaveReason.PlaybackProgress, CancellationToken.None);
}
}
@ -842,7 +838,7 @@ namespace Emby.Server.Implementations.Session
{
foreach (var user in users)
{
playedToCompletion = await OnPlaybackStopped(user.Id, libraryItem, info.PositionTicks, info.Failed).ConfigureAwait(false);
playedToCompletion = OnPlaybackStopped(user.Id, libraryItem, info.PositionTicks, info.Failed);
}
}
@ -875,7 +871,7 @@ namespace Emby.Server.Implementations.Session
await SendPlaybackStoppedNotification(session, CancellationToken.None).ConfigureAwait(false);
}
private async Task<bool> OnPlaybackStopped(Guid userId, BaseItem item, long? positionTicks, bool playbackFailed)
private bool OnPlaybackStopped(Guid userId, BaseItem item, long? positionTicks, bool playbackFailed)
{
bool playedToCompletion = false;
@ -896,7 +892,7 @@ namespace Emby.Server.Implementations.Session
playedToCompletion = true;
}
await _userDataManager.SaveUserData(userId, item, data, UserDataSaveReason.PlaybackFinished, CancellationToken.None).ConfigureAwait(false);
_userDataManager.SaveUserData(userId, item, data, UserDataSaveReason.PlaybackFinished, CancellationToken.None);
}
return playedToCompletion;
@ -1432,7 +1428,7 @@ namespace Emby.Server.Implementations.Session
user = result;
}
var token = await GetAuthorizationToken(user.Id.ToString("N"), request.DeviceId, request.App, request.AppVersion, request.DeviceName).ConfigureAwait(false);
var token = GetAuthorizationToken(user.Id.ToString("N"), request.DeviceId, request.App, request.AppVersion, request.DeviceName);
EventHelper.FireEventIfNotNull(AuthenticationSucceeded, this, new GenericEventArgs<AuthenticationRequest>(request), _logger);
@ -1454,7 +1450,7 @@ namespace Emby.Server.Implementations.Session
}
private async Task<string> GetAuthorizationToken(string userId, string deviceId, string app, string appVersion, string deviceName)
private string GetAuthorizationToken(string userId, string deviceId, string app, string appVersion, string deviceName)
{
var existing = _authRepo.Get(new AuthenticationInfoQuery
{
@ -1484,12 +1480,12 @@ namespace Emby.Server.Implementations.Session
};
_logger.Info("Creating new access token for user {0}", userId);
await _authRepo.Create(newToken, CancellationToken.None).ConfigureAwait(false);
_authRepo.Create(newToken, CancellationToken.None);
return newToken.AccessToken;
}
public async Task Logout(string accessToken)
public void Logout(string accessToken)
{
if (string.IsNullOrWhiteSpace(accessToken))
{
@ -1509,7 +1505,7 @@ namespace Emby.Server.Implementations.Session
{
existing.IsActive = false;
await _authRepo.Update(existing, CancellationToken.None).ConfigureAwait(false);
_authRepo.Update(existing, CancellationToken.None);
var sessions = Sessions
.Where(i => string.Equals(i.DeviceId, existing.DeviceId, StringComparison.OrdinalIgnoreCase))
@ -1529,7 +1525,7 @@ namespace Emby.Server.Implementations.Session
}
}
public async Task RevokeUserTokens(string userId, string currentAccessToken)
public void RevokeUserTokens(string userId, string currentAccessToken)
{
var existing = _authRepo.Get(new AuthenticationInfoQuery
{
@ -1541,14 +1537,14 @@ namespace Emby.Server.Implementations.Session
{
if (!string.Equals(currentAccessToken, info.AccessToken, StringComparison.OrdinalIgnoreCase))
{
await Logout(info.AccessToken).ConfigureAwait(false);
Logout(info.AccessToken);
}
}
}
public Task RevokeToken(string token)
public void RevokeToken(string token)
{
return Logout(token);
Logout(token);
}
/// <summary>

View File

@ -58,8 +58,8 @@ namespace Emby.Server.Implementations.Social
};
AddShareInfo(info, externalUrl);
await _repository.CreateShare(info).ConfigureAwait(false);
_repository.CreateShare(info);
return info;
}
@ -92,9 +92,9 @@ namespace Emby.Server.Implementations.Social
}
}
public Task DeleteShare(string id)
public void DeleteShare(string id)
{
return _repository.DeleteShare(id);
_repository.DeleteShare(id);
}
}
}

View File

@ -1,8 +1,6 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
using Emby.Server.Implementations.Data;
using MediaBrowser.Common.Configuration;
using MediaBrowser.Model.Logging;
@ -42,7 +40,7 @@ namespace Emby.Server.Implementations.Social
}
}
public async Task CreateShare(SocialShareInfo info)
public void CreateShare(SocialShareInfo info)
{
if (info == null)
{
@ -109,7 +107,7 @@ namespace Emby.Server.Implementations.Social
return info;
}
public async Task DeleteShare(string id)
public void DeleteShare(string id)
{
}

View File

@ -88,9 +88,7 @@ namespace MediaBrowser.Api
// Serialize to json and then back so that the core doesn't see the request dto type
var displayPreferences = _jsonSerializer.DeserializeFromString<DisplayPreferences>(_jsonSerializer.SerializeToString(request));
var task = _displayPreferencesManager.SaveDisplayPreferences(displayPreferences, request.UserId, request.Client, CancellationToken.None);
Task.WaitAll(task);
_displayPreferencesManager.SaveDisplayPreferences(displayPreferences, request.UserId, request.Client, CancellationToken.None);
}
}
}

View File

@ -209,7 +209,7 @@ namespace MediaBrowser.Api
// Do this first so that metadata savers can pull the updates from the database.
if (request.People != null)
{
await _libraryManager.UpdatePeople(item, request.People.Select(x => new PersonInfo { Name = x.Name, Role = x.Role, Type = x.Type }).ToList());
_libraryManager.UpdatePeople(item, request.People.Select(x => new PersonInfo { Name = x.Name, Role = x.Role, Type = x.Type }).ToList());
}
UpdateItem(request, item);

View File

@ -525,18 +525,18 @@ namespace MediaBrowser.Api.Library
});
}
private async void LogDownload(BaseItem item, User user, AuthorizationInfo auth)
private void LogDownload(BaseItem item, User user, AuthorizationInfo auth)
{
try
{
await _activityManager.Create(new ActivityLogEntry
_activityManager.Create(new ActivityLogEntry
{
Name = string.Format(_localization.GetLocalizedString("UserDownloadingItemWithValues"), user.Name, item.Name),
Type = "UserDownloadingContent",
ShortOverview = string.Format(_localization.GetLocalizedString("AppDeviceValues"), auth.Client, auth.Device),
UserId = auth.UserId
}).ConfigureAwait(false);
});
}
catch
{
@ -915,7 +915,7 @@ namespace MediaBrowser.Api.Library
: request.IncludeItemTypes.Split(',');
var user = !string.IsNullOrWhiteSpace(request.UserId) ? _userManager.GetUserById(request.UserId) : null;
var query = new InternalItemsQuery(user)
{
IncludeItemTypes = includeTypes,

View File

@ -313,14 +313,13 @@ namespace MediaBrowser.Api.Session
public void Delete(RevokeKey request)
{
var task = _sessionManager.RevokeToken(request.Key);
_sessionManager.RevokeToken(request.Key);
Task.WaitAll(task);
}
public void Post(CreateKey request)
{
var task = _authRepo.Create(new AuthenticationInfo
_authRepo.Create(new AuthenticationInfo
{
AppName = request.App,
IsActive = true,
@ -328,8 +327,6 @@ namespace MediaBrowser.Api.Session
DateCreated = DateTime.UtcNow
}, CancellationToken.None);
Task.WaitAll(task);
}
public void Post(ReportSessionEnded request)

View File

@ -121,8 +121,7 @@ namespace MediaBrowser.Api.Social
public void Delete(DeleteShare request)
{
var task = _sharingManager.DeleteShare(request.Id);
Task.WaitAll(task);
_sharingManager.DeleteShare(request.Id);
}
public async Task<object> Get(GetShareImage request)
@ -157,7 +156,7 @@ namespace MediaBrowser.Api.Social
}
catch
{
}
}

View File

@ -125,7 +125,7 @@ namespace MediaBrowser.Api
var user = _userManager.Users.First();
user.Name = request.Name;
await _userManager.UpdateUser(user).ConfigureAwait(false);
_userManager.UpdateUser(user);
var result = new UpdateStartupUserResult();

View File

@ -12,11 +12,9 @@ using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using MediaBrowser.Controller.Entities.Audio;
using MediaBrowser.Controller.IO;
using MediaBrowser.Model.IO;
using MediaBrowser.Controller.Providers;
using MediaBrowser.Model.Services;
using MediaBrowser.Model.Extensions;
namespace MediaBrowser.Api.UserLibrary
{
@ -507,9 +505,9 @@ namespace MediaBrowser.Api.UserLibrary
/// Posts the specified request.
/// </summary>
/// <param name="request">The request.</param>
public async Task<object> Post(MarkFavoriteItem request)
public object Post(MarkFavoriteItem request)
{
var dto = await MarkFavorite(request.UserId, request.Id, true).ConfigureAwait(false);
var dto = MarkFavorite(request.UserId, request.Id, true);
return ToOptimizedResult(dto);
}
@ -520,7 +518,7 @@ namespace MediaBrowser.Api.UserLibrary
/// <param name="request">The request.</param>
public object Delete(UnmarkFavoriteItem request)
{
var dto = MarkFavorite(request.UserId, request.Id, false).Result;
var dto = MarkFavorite(request.UserId, request.Id, false);
return ToOptimizedResult(dto);
}
@ -531,8 +529,7 @@ namespace MediaBrowser.Api.UserLibrary
/// <param name="userId">The user id.</param>
/// <param name="itemId">The item id.</param>
/// <param name="isFavorite">if set to <c>true</c> [is favorite].</param>
/// <returns>Task{UserItemDataDto}.</returns>
private async Task<UserItemDataDto> MarkFavorite(string userId, string itemId, bool isFavorite)
private UserItemDataDto MarkFavorite(string userId, string itemId, bool isFavorite)
{
var user = _userManager.GetUserById(userId);
@ -544,7 +541,7 @@ namespace MediaBrowser.Api.UserLibrary
// Set favorite status
data.IsFavorite = isFavorite;
await _userDataRepository.SaveUserData(user.Id, item, data, UserDataSaveReason.UpdateUserRating, CancellationToken.None).ConfigureAwait(false);
_userDataRepository.SaveUserData(user.Id, item, data, UserDataSaveReason.UpdateUserRating, CancellationToken.None);
return _userDataRepository.GetUserDataDto(item, user);
}
@ -555,7 +552,7 @@ namespace MediaBrowser.Api.UserLibrary
/// <param name="request">The request.</param>
public object Delete(DeleteUserItemRating request)
{
var dto = UpdateUserItemRating(request.UserId, request.Id, null).Result;
var dto = UpdateUserItemRating(request.UserId, request.Id, null);
return ToOptimizedResult(dto);
}
@ -564,9 +561,9 @@ namespace MediaBrowser.Api.UserLibrary
/// Posts the specified request.
/// </summary>
/// <param name="request">The request.</param>
public async Task<object> Post(UpdateUserItemRating request)
public object Post(UpdateUserItemRating request)
{
var dto = await UpdateUserItemRating(request.UserId, request.Id, request.Likes).ConfigureAwait(false);
var dto = UpdateUserItemRating(request.UserId, request.Id, request.Likes);
return ToOptimizedResult(dto);
}
@ -577,8 +574,7 @@ namespace MediaBrowser.Api.UserLibrary
/// <param name="userId">The user id.</param>
/// <param name="itemId">The item id.</param>
/// <param name="likes">if set to <c>true</c> [likes].</param>
/// <returns>Task{UserItemDataDto}.</returns>
private async Task<UserItemDataDto> UpdateUserItemRating(string userId, string itemId, bool? likes)
private UserItemDataDto UpdateUserItemRating(string userId, string itemId, bool? likes)
{
var user = _userManager.GetUserById(userId);
@ -589,7 +585,7 @@ namespace MediaBrowser.Api.UserLibrary
data.Likes = likes;
await _userDataRepository.SaveUserData(user.Id, item, data, UserDataSaveReason.UpdateUserRating, CancellationToken.None).ConfigureAwait(false);
_userDataRepository.SaveUserData(user.Id, item, data, UserDataSaveReason.UpdateUserRating, CancellationToken.None);
return _userDataRepository.GetUserDataDto(item, user);
}

View File

@ -387,7 +387,7 @@ namespace MediaBrowser.Api
throw new ResourceNotFoundException("User not found");
}
await _sessionMananger.RevokeUserTokens(user.Id.ToString("N"), null).ConfigureAwait(false);
_sessionMananger.RevokeUserTokens(user.Id.ToString("N"), null);
await _userManager.DeleteUser(user).ConfigureAwait(false);
}
@ -455,7 +455,7 @@ namespace MediaBrowser.Api
if (request.ResetPassword)
{
await _userManager.ResetPassword(user).ConfigureAwait(false);
_userManager.ResetPassword(user);
}
else
{
@ -466,24 +466,18 @@ namespace MediaBrowser.Api
throw new ArgumentException("Invalid user or password entered.");
}
await _userManager.ChangePassword(user, request.NewPassword).ConfigureAwait(false);
_userManager.ChangePassword(user, request.NewPassword);
var currentToken = _authContext.GetAuthorizationInfo(Request).Token;
await _sessionMananger.RevokeUserTokens(user.Id.ToString("N"), currentToken).ConfigureAwait(false);
_sessionMananger.RevokeUserTokens(user.Id.ToString("N"), currentToken);
}
}
public void Post(UpdateUserEasyPassword request)
{
var task = PostAsync(request);
Task.WaitAll(task);
}
public async Task PostAsync(UpdateUserEasyPassword request)
{
AssertCanUpdateUser(_authContext, _userManager, request.Id, true);
var user = _userManager.GetUserById(request.Id);
if (user == null)
@ -493,11 +487,11 @@ namespace MediaBrowser.Api
if (request.ResetPassword)
{
await _userManager.ResetEasyPassword(user).ConfigureAwait(false);
_userManager.ResetEasyPassword(user);
}
else
{
await _userManager.ChangeEasyPassword(user, request.NewPassword).ConfigureAwait(false);
_userManager.ChangeEasyPassword(user, request.NewPassword);
}
}
@ -506,13 +500,6 @@ namespace MediaBrowser.Api
/// </summary>
/// <param name="request">The request.</param>
public void Post(UpdateUser request)
{
var task = PostAsync(request);
Task.WaitAll(task);
}
public async Task PostAsync(UpdateUser request)
{
// We need to parse this manually because we told service stack not to with IRequiresRequestStream
// https://code.google.com/p/servicestack/source/browse/trunk/Common/ServiceStack.Text/ServiceStack.Text/Controller/PathInfo.cs
@ -524,13 +511,18 @@ namespace MediaBrowser.Api
var user = _userManager.GetUserById(id);
var task = string.Equals(user.Name, dtoUser.Name, StringComparison.Ordinal) ?
_userManager.UpdateUser(user) :
_userManager.RenameUser(user, dtoUser.Name);
if (string.Equals(user.Name, dtoUser.Name, StringComparison.Ordinal))
{
_userManager.UpdateUser(user);
}
else
{
var task = _userManager.RenameUser(user, dtoUser.Name);
await task.ConfigureAwait(false);
Task.WaitAll(task);
}
await _userManager.UpdateConfiguration(dtoUser.Id, dtoUser.Configuration);
_userManager.UpdateConfiguration(dtoUser.Id, dtoUser.Configuration);
}
/// <summary>
@ -570,21 +562,14 @@ namespace MediaBrowser.Api
{
AssertCanUpdateUser(_authContext, _userManager, request.Id, false);
var task = _userManager.UpdateConfiguration(request.Id, request);
_userManager.UpdateConfiguration(request.Id, request);
Task.WaitAll(task);
}
public void Post(UpdateUserPolicy request)
{
var task = UpdateUserPolicy(request);
Task.WaitAll(task);
}
private async Task UpdateUserPolicy(UpdateUserPolicy request)
{
var user = _userManager.GetUserById(request.Id);
// If removing admin access
if (!request.IsAdministrator && user.Policy.IsAdministrator)
{
@ -609,10 +594,10 @@ namespace MediaBrowser.Api
}
var currentToken = _authContext.GetAuthorizationInfo(Request).Token;
await _sessionMananger.RevokeUserTokens(user.Id.ToString("N"), currentToken).ConfigureAwait(false);
_sessionMananger.RevokeUserTokens(user.Id.ToString("N"), currentToken);
}
await _userManager.UpdateUserPolicy(request.Id, request).ConfigureAwait(false);
_userManager.UpdateUserPolicy(request.Id, request);
}
}
}

View File

@ -14,11 +14,11 @@ namespace MediaBrowser.Controller.Chapters
/// </summary>
/// <param name="itemId">The item identifier.</param>
/// <returns>List{ChapterInfo}.</returns>
IEnumerable<ChapterInfo> GetChapters(string itemId);
List<ChapterInfo> GetChapters(string itemId);
/// <summary>
/// Saves the chapters.
/// </summary>
Task SaveChapters(string itemId, List<ChapterInfo> chapters);
void SaveChapters(string itemId, List<ChapterInfo> chapters);
}
}

View File

@ -1771,7 +1771,7 @@ namespace MediaBrowser.Controller.Entities
/// <param name="resetPosition">if set to <c>true</c> [reset position].</param>
/// <returns>Task.</returns>
/// <exception cref="System.ArgumentNullException"></exception>
public virtual async Task MarkPlayed(User user,
public virtual void MarkPlayed(User user,
DateTime? datePlayed,
bool resetPosition)
{
@ -1799,7 +1799,7 @@ namespace MediaBrowser.Controller.Entities
data.LastPlayedDate = datePlayed ?? data.LastPlayedDate ?? DateTime.UtcNow;
data.Played = true;
await UserDataManager.SaveUserData(user.Id, this, data, UserDataSaveReason.TogglePlayed, CancellationToken.None).ConfigureAwait(false);
UserDataManager.SaveUserData(user.Id, this, data, UserDataSaveReason.TogglePlayed, CancellationToken.None);
}
/// <summary>
@ -1808,7 +1808,7 @@ namespace MediaBrowser.Controller.Entities
/// <param name="user">The user.</param>
/// <returns>Task.</returns>
/// <exception cref="System.ArgumentNullException"></exception>
public virtual async Task MarkUnplayed(User user)
public virtual void MarkUnplayed(User user)
{
if (user == null)
{
@ -1825,7 +1825,7 @@ namespace MediaBrowser.Controller.Entities
data.LastPlayedDate = null;
data.Played = false;
await UserDataManager.SaveUserData(user.Id, this, data, UserDataSaveReason.TogglePlayed, CancellationToken.None).ConfigureAwait(false);
UserDataManager.SaveUserData(user.Id, this, data, UserDataSaveReason.TogglePlayed, CancellationToken.None);
}
/// <summary>

View File

@ -186,7 +186,7 @@ namespace MediaBrowser.Controller.Entities
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Task.</returns>
/// <exception cref="System.InvalidOperationException">Unable to add + item.Name</exception>
public async Task AddChild(BaseItem item, CancellationToken cancellationToken)
public void AddChild(BaseItem item, CancellationToken cancellationToken)
{
item.SetParent(this);
@ -209,7 +209,7 @@ namespace MediaBrowser.Controller.Entities
item.DateModified = DateTime.UtcNow;
}
await LibraryManager.CreateItem(item, cancellationToken).ConfigureAwait(false);
LibraryManager.CreateItem(item, cancellationToken);
}
/// <summary>
@ -469,7 +469,7 @@ namespace MediaBrowser.Controller.Entities
}
}
await LibraryManager.CreateItems(newItems, cancellationToken).ConfigureAwait(false);
LibraryManager.CreateItems(newItems, cancellationToken);
}
}
else
@ -1370,7 +1370,7 @@ namespace MediaBrowser.Controller.Entities
/// <param name="datePlayed">The date played.</param>
/// <param name="resetPosition">if set to <c>true</c> [reset position].</param>
/// <returns>Task.</returns>
public override async Task MarkPlayed(User user,
public override void MarkPlayed(User user,
DateTime? datePlayed,
bool resetPosition)
{
@ -1390,9 +1390,10 @@ namespace MediaBrowser.Controller.Entities
var itemsResult = GetItemList(query);
// Sweep through recursively and update status
var tasks = itemsResult.Select(c => c.MarkPlayed(user, datePlayed, resetPosition));
await Task.WhenAll(tasks).ConfigureAwait(false);
foreach (var item in itemsResult)
{
item.MarkPlayed(user, datePlayed, resetPosition);
}
}
/// <summary>
@ -1400,7 +1401,7 @@ namespace MediaBrowser.Controller.Entities
/// </summary>
/// <param name="user">The user.</param>
/// <returns>Task.</returns>
public override async Task MarkUnplayed(User user)
public override void MarkUnplayed(User user)
{
var itemsResult = GetItemList(new InternalItemsQuery
{
@ -1412,9 +1413,10 @@ namespace MediaBrowser.Controller.Entities
});
// Sweep through recursively and update status
var tasks = itemsResult.Select(c => c.MarkUnplayed(user));
await Task.WhenAll(tasks).ConfigureAwait(false);
foreach (var item in itemsResult)
{
item.MarkUnplayed(user);
}
}
public override bool IsPlayed(User user)

View File

@ -165,7 +165,7 @@ namespace MediaBrowser.Controller.Entities
}
}
}
return _policy;
}
set { _policy = value; }
@ -194,24 +194,24 @@ namespace MediaBrowser.Controller.Entities
var oldConfigurationDirectory = ConfigurationDirectoryPath;
// Exceptions will be thrown if these paths already exist
if (FileSystem.DirectoryExists(newConfigDirectory))
if (FileSystem.DirectoryExists(newConfigDirectory))
{
FileSystem.DeleteDirectory(newConfigDirectory, true);
}
if (FileSystem.DirectoryExists(oldConfigurationDirectory))
if (FileSystem.DirectoryExists(oldConfigurationDirectory))
{
FileSystem.MoveDirectory(oldConfigurationDirectory, newConfigDirectory);
FileSystem.MoveDirectory(oldConfigurationDirectory, newConfigDirectory);
}
else
{
FileSystem.CreateDirectory(newConfigDirectory);
FileSystem.CreateDirectory(newConfigDirectory);
}
}
Name = newName;
return RefreshMetadata(new MetadataRefreshOptions(new DirectoryService(Logger, FileSystem))
return RefreshMetadata(new MetadataRefreshOptions(new DirectoryService(Logger, FileSystem))
{
ReplaceAllMetadata = true,
ImageRefreshMode = ImageRefreshMode.FullRefresh,
@ -223,7 +223,8 @@ namespace MediaBrowser.Controller.Entities
public override Task UpdateToRepository(ItemUpdateType updateReason, CancellationToken cancellationToken)
{
return UserManager.UpdateUser(this);
UserManager.UpdateUser(this);
return Task.FromResult(true);
}
/// <summary>

View File

@ -195,16 +195,14 @@ namespace MediaBrowser.Controller.Library
/// </summary>
/// <param name="item">The item.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Task.</returns>
Task CreateItem(BaseItem item, CancellationToken cancellationToken);
void CreateItem(BaseItem item, CancellationToken cancellationToken);
/// <summary>
/// Creates the items.
/// </summary>
/// <param name="items">The items.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Task.</returns>
Task CreateItems(IEnumerable<BaseItem> items, CancellationToken cancellationToken);
void CreateItems(IEnumerable<BaseItem> items, CancellationToken cancellationToken);
/// <summary>
/// Updates the item.
@ -303,7 +301,7 @@ namespace MediaBrowser.Controller.Library
/// <param name="sortName">Name of the sort.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Task&lt;UserView&gt;.</returns>
Task<UserView> GetNamedView(User user,
UserView GetNamedView(User user,
string name,
string parentId,
string viewType,
@ -319,7 +317,7 @@ namespace MediaBrowser.Controller.Library
/// <param name="sortName">Name of the sort.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Task&lt;UserView&gt;.</returns>
Task<UserView> GetNamedView(User user,
UserView GetNamedView(User user,
string name,
string viewType,
string sortName,
@ -363,7 +361,7 @@ namespace MediaBrowser.Controller.Library
/// <param name="sortName">Name of the sort.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Task&lt;UserView&gt;.</returns>
Task<UserView> GetShadowView(BaseItem parent,
UserView GetShadowView(BaseItem parent,
string viewType,
string sortName,
CancellationToken cancellationToken);
@ -471,8 +469,7 @@ namespace MediaBrowser.Controller.Library
/// </summary>
/// <param name="item">The item.</param>
/// <param name="people">The people.</param>
/// <returns>Task.</returns>
Task UpdatePeople(BaseItem item, List<PersonInfo> people);
void UpdatePeople(BaseItem item, List<PersonInfo> people);
/// <summary>
/// Gets the item ids.

View File

@ -4,7 +4,6 @@ using MediaBrowser.Model.Dto;
using MediaBrowser.Model.Entities;
using System;
using System.Threading;
using System.Threading.Tasks;
using MediaBrowser.Model.Querying;
namespace MediaBrowser.Controller.Library
@ -28,7 +27,7 @@ namespace MediaBrowser.Controller.Library
/// <param name="reason">The reason.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Task.</returns>
Task SaveUserData(Guid userId, IHasUserData item, UserItemData userData, UserDataSaveReason reason, CancellationToken cancellationToken);
void SaveUserData(Guid userId, IHasUserData item, UserItemData userData, UserDataSaveReason reason, CancellationToken cancellationToken);
UserItemData GetUserData(IHasUserData user, IHasUserData item);
@ -47,7 +46,7 @@ namespace MediaBrowser.Controller.Library
/// </summary>
/// <param name="userId"></param>
/// <returns></returns>
IEnumerable<UserItemData> GetAllUserData(Guid userId);
List<UserItemData> GetAllUserData(Guid userId);
/// <summary>
/// Save the all provided user data for the given user
@ -56,7 +55,7 @@ namespace MediaBrowser.Controller.Library
/// <param name="userData"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
Task SaveAllUserData(Guid userId, IEnumerable<UserItemData> userData, CancellationToken cancellationToken);
void SaveAllUserData(Guid userId, UserItemData[] userData, CancellationToken cancellationToken);
/// <summary>
/// Updates playstate for an item and returns true or false indicating if it was played to completion

View File

@ -91,7 +91,7 @@ namespace MediaBrowser.Controller.Library
/// <param name="user">The user.</param>
/// <exception cref="System.ArgumentNullException">user</exception>
/// <exception cref="System.ArgumentException"></exception>
Task UpdateUser(User user);
void UpdateUser(User user);
/// <summary>
/// Creates the user.
@ -116,7 +116,7 @@ namespace MediaBrowser.Controller.Library
/// </summary>
/// <param name="user">The user.</param>
/// <returns>Task.</returns>
Task ResetPassword(User user);
void ResetPassword(User user);
/// <summary>
/// Gets the offline user dto.
@ -130,7 +130,7 @@ namespace MediaBrowser.Controller.Library
/// </summary>
/// <param name="user">The user.</param>
/// <returns>Task.</returns>
Task ResetEasyPassword(User user);
void ResetEasyPassword(User user);
/// <summary>
/// Changes the password.
@ -138,7 +138,7 @@ namespace MediaBrowser.Controller.Library
/// <param name="user">The user.</param>
/// <param name="newPasswordSha1">The new password sha1.</param>
/// <returns>Task.</returns>
Task ChangePassword(User user, string newPasswordSha1);
void ChangePassword(User user, string newPasswordSha1);
/// <summary>
/// Changes the easy password.
@ -146,7 +146,7 @@ namespace MediaBrowser.Controller.Library
/// <param name="user">The user.</param>
/// <param name="newPasswordSha1">The new password sha1.</param>
/// <returns>Task.</returns>
Task ChangeEasyPassword(User user, string newPasswordSha1);
void ChangeEasyPassword(User user, string newPasswordSha1);
/// <summary>
/// Gets the user dto.
@ -179,7 +179,7 @@ namespace MediaBrowser.Controller.Library
/// </summary>
/// <param name="pin">The pin.</param>
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
Task<PinRedeemResult> RedeemPasswordResetPin(string pin);
PinRedeemResult RedeemPasswordResetPin(string pin);
/// <summary>
/// Gets the user policy.
@ -201,14 +201,14 @@ namespace MediaBrowser.Controller.Library
/// <param name="userId">The user identifier.</param>
/// <param name="newConfiguration">The new configuration.</param>
/// <returns>Task.</returns>
Task UpdateConfiguration(string userId, UserConfiguration newConfiguration);
void UpdateConfiguration(string userId, UserConfiguration newConfiguration);
/// <summary>
/// Updates the user policy.
/// </summary>
/// <param name="userId">The user identifier.</param>
/// <param name="userPolicy">The user policy.</param>
Task UpdateUserPolicy(string userId, UserPolicy userPolicy);
void UpdateUserPolicy(string userId, UserPolicy userPolicy);
/// <summary>
/// Makes the valid username.

View File

@ -2,7 +2,6 @@
using MediaBrowser.Model.Entities;
using System;
using System.Threading;
using System.Threading.Tasks;
namespace MediaBrowser.Controller.Persistence
{
@ -19,9 +18,9 @@ namespace MediaBrowser.Controller.Persistence
/// <param name="client">The client.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Task.</returns>
Task SaveDisplayPreferences(DisplayPreferences displayPreferences, string userId, string client,
void SaveDisplayPreferences(DisplayPreferences displayPreferences, string userId, string client,
CancellationToken cancellationToken);
/// <summary>
/// Saves all display preferences for a user
/// </summary>
@ -29,7 +28,7 @@ namespace MediaBrowser.Controller.Persistence
/// <param name="userId">The user id.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Task.</returns>
Task SaveAllDisplayPreferences(IEnumerable<DisplayPreferences> displayPreferences, Guid userId,
void SaveAllDisplayPreferences(IEnumerable<DisplayPreferences> displayPreferences, Guid userId,
CancellationToken cancellationToken);
/// <summary>
/// Gets the display preferences.

View File

@ -3,7 +3,6 @@ using MediaBrowser.Model.Entities;
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using MediaBrowser.Model.Dto;
using MediaBrowser.Model.Querying;
@ -19,16 +18,14 @@ namespace MediaBrowser.Controller.Persistence
/// </summary>
/// <param name="item">The item.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Task.</returns>
Task SaveItem(BaseItem item, CancellationToken cancellationToken);
void SaveItem(BaseItem item, CancellationToken cancellationToken);
/// <summary>
/// Deletes the item.
/// </summary>
/// <param name="id">The identifier.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Task.</returns>
Task DeleteItem(Guid id, CancellationToken cancellationToken);
void DeleteItem(Guid id, CancellationToken cancellationToken);
/// <summary>
/// Gets the critic reviews.
@ -42,16 +39,14 @@ namespace MediaBrowser.Controller.Persistence
/// </summary>
/// <param name="itemId">The item id.</param>
/// <param name="criticReviews">The critic reviews.</param>
/// <returns>Task.</returns>
Task SaveCriticReviews(Guid itemId, IEnumerable<ItemReview> criticReviews);
void SaveCriticReviews(Guid itemId, IEnumerable<ItemReview> criticReviews);
/// <summary>
/// Saves the items.
/// </summary>
/// <param name="items">The items.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Task.</returns>
Task SaveItems(List<BaseItem> items, CancellationToken cancellationToken);
void SaveItems(List<BaseItem> items, CancellationToken cancellationToken);
/// <summary>
/// Retrieves the item.
@ -78,7 +73,7 @@ namespace MediaBrowser.Controller.Persistence
/// <summary>
/// Saves the chapters.
/// </summary>
Task SaveChapters(Guid id, List<ChapterInfo> chapters);
void SaveChapters(Guid id, List<ChapterInfo> chapters);
/// <summary>
/// Gets the media streams.
@ -93,8 +88,7 @@ namespace MediaBrowser.Controller.Persistence
/// <param name="id">The identifier.</param>
/// <param name="streams">The streams.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Task.</returns>
Task SaveMediaStreams(Guid id, List<MediaStream> streams, CancellationToken cancellationToken);
void SaveMediaStreams(Guid id, List<MediaStream> streams, CancellationToken cancellationToken);
/// <summary>
/// Gets the item ids.
@ -128,8 +122,7 @@ namespace MediaBrowser.Controller.Persistence
/// </summary>
/// <param name="itemId">The item identifier.</param>
/// <param name="people">The people.</param>
/// <returns>Task.</returns>
Task UpdatePeople(Guid itemId, List<PersonInfo> people);
void UpdatePeople(Guid itemId, List<PersonInfo> people);
/// <summary>
/// Gets the people names.
@ -156,8 +149,7 @@ namespace MediaBrowser.Controller.Persistence
/// Updates the inherited values.
/// </summary>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Task.</returns>
Task UpdateInheritedValues(CancellationToken cancellationToken);
void UpdateInheritedValues(CancellationToken cancellationToken);
int GetCount(InternalItemsQuery query);

View File

@ -2,7 +2,6 @@
using MediaBrowser.Controller.Entities;
using System;
using System.Threading;
using System.Threading.Tasks;
namespace MediaBrowser.Controller.Persistence
{
@ -19,7 +18,7 @@ namespace MediaBrowser.Controller.Persistence
/// <param name="userData">The user data.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Task.</returns>
Task SaveUserData(Guid userId, string key, UserItemData userData, CancellationToken cancellationToken);
void SaveUserData(Guid userId, string key, UserItemData userData, CancellationToken cancellationToken);
/// <summary>
/// Gets the user data.
@ -36,7 +35,7 @@ namespace MediaBrowser.Controller.Persistence
/// </summary>
/// <param name="userId"></param>
/// <returns></returns>
IEnumerable<UserItemData> GetAllUserData(Guid userId);
List<UserItemData> GetAllUserData(Guid userId);
/// <summary>
/// Save all user data associated with the given user
@ -45,7 +44,7 @@ namespace MediaBrowser.Controller.Persistence
/// <param name="userData"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
Task SaveAllUserData(Guid userId, IEnumerable<UserItemData> userData, CancellationToken cancellationToken);
void SaveAllUserData(Guid userId, UserItemData[] userData, CancellationToken cancellationToken);
}
}

View File

@ -1,7 +1,6 @@
using MediaBrowser.Controller.Entities;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
namespace MediaBrowser.Controller.Persistence
{
@ -16,7 +15,7 @@ namespace MediaBrowser.Controller.Persistence
/// <param name="user">The user.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Task.</returns>
Task DeleteUser(User user, CancellationToken cancellationToken);
void DeleteUser(User user, CancellationToken cancellationToken);
/// <summary>
/// Saves the user.
@ -24,7 +23,7 @@ namespace MediaBrowser.Controller.Persistence
/// <param name="user">The user.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Task.</returns>
Task SaveUser(User user, CancellationToken cancellationToken);
void SaveUser(User user, CancellationToken cancellationToken);
/// <summary>
/// Retrieves all users.

View File

@ -1,6 +1,5 @@
using MediaBrowser.Model.Querying;
using System.Threading;
using System.Threading.Tasks;
namespace MediaBrowser.Controller.Security
{
@ -12,7 +11,7 @@ namespace MediaBrowser.Controller.Security
/// <param name="info">The information.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Task.</returns>
Task Create(AuthenticationInfo info, CancellationToken cancellationToken);
void Create(AuthenticationInfo info, CancellationToken cancellationToken);
/// <summary>
/// Updates the specified information.
@ -20,7 +19,7 @@ namespace MediaBrowser.Controller.Security
/// <param name="info">The information.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Task.</returns>
Task Update(AuthenticationInfo info, CancellationToken cancellationToken);
void Update(AuthenticationInfo info, CancellationToken cancellationToken);
/// <summary>
/// Gets the specified query.

View File

@ -318,19 +318,19 @@ namespace MediaBrowser.Controller.Session
/// </summary>
/// <param name="accessToken">The access token.</param>
/// <returns>Task.</returns>
Task Logout(string accessToken);
void Logout(string accessToken);
/// <summary>
/// Revokes the user tokens.
/// </summary>
/// <returns>Task.</returns>
Task RevokeUserTokens(string userId, string currentAccessToken);
void RevokeUserTokens(string userId, string currentAccessToken);
/// <summary>
/// Revokes the token.
/// </summary>
/// <param name="id">The identifier.</param>
/// <returns>Task.</returns>
Task RevokeToken(string id);
void RevokeToken(string id);
}
}

View File

@ -1,5 +1,4 @@
using System;
using System.Threading.Tasks;
using MediaBrowser.Model.Events;
using MediaBrowser.Model.Querying;
@ -9,7 +8,7 @@ namespace MediaBrowser.Model.Activity
{
event EventHandler<GenericEventArgs<ActivityLogEntry>> EntryCreated;
Task Create(ActivityLogEntry entry);
void Create(ActivityLogEntry entry);
QueryResult<ActivityLogEntry> GetActivityLogEntries(DateTime? minDate, int? startIndex, int? limit);
}

View File

@ -1,12 +1,11 @@
using System;
using System.Threading.Tasks;
using MediaBrowser.Model.Querying;
namespace MediaBrowser.Model.Activity
{
public interface IActivityRepository
{
Task Create(ActivityLogEntry entry);
void Create(ActivityLogEntry entry);
QueryResult<ActivityLogEntry> GetActivityLogEntries(DateTime? minDate, int? startIndex, int? limit);
}

View File

@ -22,6 +22,6 @@ namespace MediaBrowser.Model.Social
/// </summary>
/// <param name="id">The identifier.</param>
/// <returns>Task.</returns>
Task DeleteShare(string id);
void DeleteShare(string id);
}
}

View File

@ -1,11 +1,10 @@
using System.Threading.Tasks;

namespace MediaBrowser.Model.Social
{
public interface ISharingRepository
{
Task CreateShare(SocialShareInfo info);
Task DeleteShare(string id);
void CreateShare(SocialShareInfo info);
void DeleteShare(string id);
SocialShareInfo GetShareInfo(string id);
}
}

View File

@ -33,14 +33,14 @@ namespace MediaBrowser.Providers.Chapters
_itemRepo = itemRepo;
}
public IEnumerable<ChapterInfo> GetChapters(string itemId)
public List<ChapterInfo> GetChapters(string itemId)
{
return _itemRepo.GetChapters(new Guid(itemId));
}
public Task SaveChapters(string itemId, List<ChapterInfo> chapters)
public void SaveChapters(string itemId, List<ChapterInfo> chapters)
{
return _itemRepo.SaveChapters(new Guid(itemId), chapters);
_itemRepo.SaveChapters(new Guid(itemId), chapters);
}
}
}

View File

@ -201,7 +201,7 @@ namespace MediaBrowser.Providers.Manager
{
var baseItem = result.Item as BaseItem;
await LibraryManager.UpdatePeople(baseItem, result.People);
LibraryManager.UpdatePeople(baseItem, result.People);
await SavePeopleMetadata(result.People, libraryOptions, cancellationToken).ConfigureAwait(false);
}
await result.Item.UpdateToRepository(reason, cancellationToken).ConfigureAwait(false);
@ -519,7 +519,7 @@ namespace MediaBrowser.Providers.Manager
userDataList.AddRange(localItem.UserDataList);
}
MergeData(localItem, temp, new MetadataFields[]{}, !options.ReplaceAllMetadata, true);
MergeData(localItem, temp, new MetadataFields[] { }, !options.ReplaceAllMetadata, true);
refreshResult.UpdateType = refreshResult.UpdateType | ItemUpdateType.MetadataImport;
// Only one local provider allowed per item
@ -567,7 +567,7 @@ namespace MediaBrowser.Providers.Manager
else
{
// TODO: If the new metadata from above has some blank data, this can cause old data to get filled into those empty fields
MergeData(metadata, temp, new MetadataFields[]{}, false, false);
MergeData(metadata, temp, new MetadataFields[] { }, false, false);
MergeData(temp, metadata, item.LockedFields, true, false);
}
}
@ -580,7 +580,7 @@ namespace MediaBrowser.Providers.Manager
await RunCustomProvider(provider, item, logName, options, refreshResult, cancellationToken).ConfigureAwait(false);
}
await ImportUserData(item, userDataList, cancellationToken).ConfigureAwait(false);
ImportUserData(item, userDataList, cancellationToken);
return refreshResult;
}
@ -595,7 +595,7 @@ namespace MediaBrowser.Providers.Manager
return true;
}
private async Task ImportUserData(TItemType item, List<UserItemData> userDataList, CancellationToken cancellationToken)
private void ImportUserData(TItemType item, List<UserItemData> userDataList, CancellationToken cancellationToken)
{
var hasUserData = item as IHasUserData;
@ -603,8 +603,7 @@ namespace MediaBrowser.Providers.Manager
{
foreach (var userData in userDataList)
{
await UserDataManager.SaveUserData(userData.UserId, hasUserData, userData, UserDataSaveReason.Import, cancellationToken)
.ConfigureAwait(false);
UserDataManager.SaveUserData(userData.UserId, hasUserData, userData, UserDataSaveReason.Import, cancellationToken);
}
}
}
@ -704,7 +703,7 @@ namespace MediaBrowser.Providers.Manager
foreach (var result in results)
{
MergeData(result, temp, new MetadataFields[]{}, false, false);
MergeData(result, temp, new MetadataFields[] { }, false, false);
}
return refreshResult;

View File

@ -43,7 +43,7 @@ namespace MediaBrowser.Providers.MediaInfo
cancellationToken.ThrowIfCancellationRequested();
await Fetch(item, cancellationToken, result).ConfigureAwait(false);
Fetch(item, cancellationToken, result);
return ItemUpdateType.MetadataImport;
}
@ -92,7 +92,7 @@ namespace MediaBrowser.Providers.MediaInfo
/// <param name="cancellationToken">The cancellation token.</param>
/// <param name="mediaInfo">The media information.</param>
/// <returns>Task.</returns>
protected async Task Fetch(Audio audio, CancellationToken cancellationToken, Model.MediaInfo.MediaInfo mediaInfo)
protected void Fetch(Audio audio, CancellationToken cancellationToken, Model.MediaInfo.MediaInfo mediaInfo)
{
var mediaStreams = mediaInfo.MediaStreams;
@ -102,12 +102,12 @@ namespace MediaBrowser.Providers.MediaInfo
audio.RunTimeTicks = mediaInfo.RunTimeTicks;
audio.Size = mediaInfo.Size;
var extension = (Path.GetExtension(audio.Path) ?? string.Empty).TrimStart('.');
//var extension = (Path.GetExtension(audio.Path) ?? string.Empty).TrimStart('.');
//audio.Container = extension;
await FetchDataFromTags(audio, mediaInfo).ConfigureAwait(false);
FetchDataFromTags(audio, mediaInfo);
await _itemRepo.SaveMediaStreams(audio.Id, mediaStreams, cancellationToken).ConfigureAwait(false);
_itemRepo.SaveMediaStreams(audio.Id, mediaStreams, cancellationToken);
}
/// <summary>
@ -115,7 +115,7 @@ namespace MediaBrowser.Providers.MediaInfo
/// </summary>
/// <param name="audio">The audio.</param>
/// <param name="data">The data.</param>
private async Task FetchDataFromTags(Audio audio, Model.MediaInfo.MediaInfo data)
private void FetchDataFromTags(Audio audio, Model.MediaInfo.MediaInfo data)
{
// Only set Name if title was found in the dictionary
if (!string.IsNullOrEmpty(data.Name))
@ -137,7 +137,7 @@ namespace MediaBrowser.Providers.MediaInfo
});
}
await _libraryManager.UpdatePeople(audio, people).ConfigureAwait(false);
_libraryManager.UpdatePeople(audio, people);
}
audio.Album = data.Album;

View File

@ -198,7 +198,7 @@ namespace MediaBrowser.Providers.MediaInfo
var libraryOptions = _libraryManager.GetLibraryOptions(video);
FetchEmbeddedInfo(video, mediaInfo, options, libraryOptions);
await FetchPeople(video, mediaInfo, options).ConfigureAwait(false);
FetchPeople(video, mediaInfo, options);
video.IsHD = mediaStreams.Any(i => i.Type == MediaStreamType.Video && i.Width.HasValue && i.Width.Value >= 1260);
@ -211,7 +211,7 @@ namespace MediaBrowser.Providers.MediaInfo
video.Video3DFormat = video.Video3DFormat ?? mediaInfo.Video3DFormat;
await _itemRepo.SaveMediaStreams(video.Id, mediaStreams, cancellationToken).ConfigureAwait(false);
_itemRepo.SaveMediaStreams(video.Id, mediaStreams, cancellationToken);
if (options.MetadataRefreshMode == MetadataRefreshMode.FullRefresh ||
options.MetadataRefreshMode == MetadataRefreshMode.Default)
@ -231,7 +231,7 @@ namespace MediaBrowser.Providers.MediaInfo
await _encodingManager.RefreshChapterImages(video, chapters, extractDuringScan, false, cancellationToken).ConfigureAwait(false);
await _chapterManager.SaveChapters(video.Id.ToString(), chapters).ConfigureAwait(false);
_chapterManager.SaveChapters(video.Id.ToString(), chapters);
}
}
@ -426,7 +426,7 @@ namespace MediaBrowser.Providers.MediaInfo
}
}
private async Task FetchPeople(Video video, Model.MediaInfo.MediaInfo data, MetadataRefreshOptions options)
private void FetchPeople(Video video, Model.MediaInfo.MediaInfo data, MetadataRefreshOptions options)
{
var isFullRefresh = options.MetadataRefreshMode == MetadataRefreshMode.FullRefresh;
@ -446,7 +446,7 @@ namespace MediaBrowser.Providers.MediaInfo
});
}
await _libraryManager.UpdatePeople(video, people);
_libraryManager.UpdatePeople(video, people);
}
}
}
@ -560,7 +560,7 @@ namespace MediaBrowser.Providers.MediaInfo
titleNumber = primaryTitle.VideoTitleSetNumber;
item.RunTimeTicks = GetRuntime(primaryTitle);
}
return _mediaEncoder.GetPrimaryPlaylistVobFiles(item.Path, mount, titleNumber)
.Select(Path.GetFileName)
.ToArray();

View File

@ -37,7 +37,7 @@ namespace MediaBrowser.Providers.TV
public async Task Run(Series series, CancellationToken cancellationToken)
{
await RemoveObsoleteSeasons(series).ConfigureAwait(false);
var hasNewSeasons = await AddDummySeasonFolders(series, cancellationToken).ConfigureAwait(false);
if (hasNewSeasons)
@ -129,8 +129,8 @@ namespace MediaBrowser.Providers.TV
};
season.SetParent(series);
await series.AddChild(season, cancellationToken).ConfigureAwait(false);
series.AddChild(season, cancellationToken);
await season.RefreshMetadata(new MetadataRefreshOptions(_fileSystem), cancellationToken).ConfigureAwait(false);

View File

@ -206,7 +206,7 @@ namespace MediaBrowser.Providers.TV
{
var existingEpisodes = (from s in series
from c in s.GetRecursiveChildren(i => i is Episode).Cast<Episode>()
select new Tuple<int, Episode>((c.ParentIndexNumber ?? 0) , c))
select new Tuple<int, Episode>((c.ParentIndexNumber ?? 0), c))
.ToList();
var lookup = episodeLookup as IList<Tuple<int, int>> ?? episodeLookup.ToList();
@ -466,7 +466,7 @@ namespace MediaBrowser.Providers.TV
episode.SetParent(season);
await season.AddChild(episode, cancellationToken).ConfigureAwait(false);
season.AddChild(episode, cancellationToken);
await episode.RefreshMetadata(new MetadataRefreshOptions(_fileSystem), cancellationToken).ConfigureAwait(false);
}
@ -534,7 +534,7 @@ namespace MediaBrowser.Providers.TV
settings.CheckCharacters = false;
settings.IgnoreProcessingInstructions = true;
settings.IgnoreComments = true;
// Use XmlReader for best performance
using (var reader = XmlReader.Create(streamReader, settings))
{

View File

@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata>
<id>MediaBrowser.Common</id>
<version>3.0.744</version>
<version>3.0.747</version>
<title>Emby.Common</title>
<authors>Emby Team</authors>
<owners>ebr,Luke,scottisafool</owners>

View File

@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>MediaBrowser.Server.Core</id>
<version>3.0.744</version>
<version>3.0.747</version>
<title>Emby.Server.Core</title>
<authors>Emby Team</authors>
<owners>ebr,Luke,scottisafool</owners>
@ -12,7 +12,7 @@
<description>Contains core components required to build plugins for Emby Server.</description>
<copyright>Copyright © Emby 2013</copyright>
<dependencies>
<dependency id="MediaBrowser.Common" version="3.0.744" />
<dependency id="MediaBrowser.Common" version="3.0.747" />
</dependencies>
</metadata>
<files>