aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Api
diff options
context:
space:
mode:
authorBond-009 <bond.009@outlook.com>2019-01-30 16:57:15 +0100
committerGitHub <noreply@github.com>2019-01-30 16:57:15 +0100
commit1ea219bf3f5c0708c3afa5fa2d897ca5212b5e04 (patch)
treeb3478e7210659ef7fa1e305e814c188ffd152fea /MediaBrowser.Api
parenta709cbdc64de36a1ce989636a19344af61d9026d (diff)
parentffcf6bdd3aaad5068decf84b0400e433fdb8323c (diff)
Merge branch 'master' into culture
Diffstat (limited to 'MediaBrowser.Api')
-rw-r--r--MediaBrowser.Api/ApiEntryPoint.cs2
-rw-r--r--MediaBrowser.Api/EnvironmentService.cs10
-rw-r--r--MediaBrowser.Api/Images/ImageByNameService.cs20
-rw-r--r--MediaBrowser.Api/Images/RemoteImageService.cs12
-rw-r--r--MediaBrowser.Api/ItemLookupService.cs12
-rw-r--r--MediaBrowser.Api/Library/LibraryStructureService.cs8
-rw-r--r--MediaBrowser.Api/Playback/BaseStreamingService.cs6
-rw-r--r--MediaBrowser.Api/Playback/Hls/BaseHlsService.cs6
-rw-r--r--MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs16
-rw-r--r--MediaBrowser.Api/Playback/Progressive/BaseProgressiveStreamingService.cs5
-rw-r--r--MediaBrowser.Api/PluginService.cs26
-rw-r--r--MediaBrowser.Api/StartupWizardService.cs9
-rw-r--r--MediaBrowser.Api/UserLibrary/PlaystateService.cs10
13 files changed, 70 insertions, 72 deletions
diff --git a/MediaBrowser.Api/ApiEntryPoint.cs b/MediaBrowser.Api/ApiEntryPoint.cs
index 8ae0ad942..763535129 100644
--- a/MediaBrowser.Api/ApiEntryPoint.cs
+++ b/MediaBrowser.Api/ApiEntryPoint.cs
@@ -646,7 +646,7 @@ namespace MediaBrowser.Api
/// <param name="outputFilePath">The output file path.</param>
private void DeleteHlsPartialStreamFiles(string outputFilePath)
{
- var directory = _fileSystem.GetDirectoryName(outputFilePath);
+ var directory = Path.GetDirectoryName(outputFilePath);
var name = Path.GetFileNameWithoutExtension(outputFilePath);
var filesToDelete = _fileSystem.GetFilePaths(directory)
diff --git a/MediaBrowser.Api/EnvironmentService.cs b/MediaBrowser.Api/EnvironmentService.cs
index 0fc20749f..bdd7a8f8f 100644
--- a/MediaBrowser.Api/EnvironmentService.cs
+++ b/MediaBrowser.Api/EnvironmentService.cs
@@ -137,14 +137,14 @@ namespace MediaBrowser.Api
{
if (request.IsFile.Value)
{
- if (!_fileSystem.FileExists(request.Path))
+ if (!File.Exists(request.Path))
{
throw new FileNotFoundException("File not found", request.Path);
}
}
else
{
- if (!_fileSystem.DirectoryExists(request.Path))
+ if (!Directory.Exists(request.Path))
{
throw new FileNotFoundException("File not found", request.Path);
}
@@ -153,7 +153,7 @@ namespace MediaBrowser.Api
else
{
- if (!_fileSystem.FileExists(request.Path) && !_fileSystem.DirectoryExists(request.Path))
+ if (!File.Exists(request.Path) && !Directory.Exists(request.Path))
{
throw new FileNotFoundException("Path not found", request.Path);
}
@@ -169,7 +169,7 @@ namespace MediaBrowser.Api
{
var file = Path.Combine(path, Guid.NewGuid().ToString());
- _fileSystem.WriteAllText(file, string.Empty);
+ File.WriteAllText(file, string.Empty);
_fileSystem.DeleteFile(file);
}
@@ -303,7 +303,7 @@ namespace MediaBrowser.Api
public object Get(GetParentPath request)
{
- var parent = _fileSystem.GetDirectoryName(request.Path);
+ var parent = Path.GetDirectoryName(request.Path);
if (string.IsNullOrEmpty(parent))
{
diff --git a/MediaBrowser.Api/Images/ImageByNameService.cs b/MediaBrowser.Api/Images/ImageByNameService.cs
index 9334e7eea..922bd8ed6 100644
--- a/MediaBrowser.Api/Images/ImageByNameService.cs
+++ b/MediaBrowser.Api/Images/ImageByNameService.cs
@@ -158,7 +158,7 @@ namespace MediaBrowser.Api.Images
private string GetThemeName(string path, string rootImagePath)
{
- var parentName = _fileSystem.GetDirectoryName(path);
+ var parentName = Path.GetDirectoryName(path);
if (string.Equals(parentName, rootImagePath, StringComparison.OrdinalIgnoreCase))
{
@@ -185,7 +185,7 @@ namespace MediaBrowser.Api.Images
var paths = BaseItem.SupportedImageExtensions.Select(i => Path.Combine(_appPaths.GeneralPath, request.Name, filename + i)).ToList();
- var path = paths.FirstOrDefault(_fileSystem.FileExists) ?? paths.FirstOrDefault();
+ var path = paths.FirstOrDefault(File.Exists) ?? paths.FirstOrDefault();
return _resultFactory.GetStaticFileResult(Request, path);
}
@@ -199,11 +199,11 @@ namespace MediaBrowser.Api.Images
{
var themeFolder = Path.Combine(_appPaths.RatingsPath, request.Theme);
- if (_fileSystem.DirectoryExists(themeFolder))
+ if (Directory.Exists(themeFolder))
{
var path = BaseItem.SupportedImageExtensions
.Select(i => Path.Combine(themeFolder, request.Name + i))
- .FirstOrDefault(_fileSystem.FileExists);
+ .FirstOrDefault(File.Exists);
if (!string.IsNullOrEmpty(path))
{
@@ -213,14 +213,14 @@ namespace MediaBrowser.Api.Images
var allFolder = Path.Combine(_appPaths.RatingsPath, "all");
- if (_fileSystem.DirectoryExists(allFolder))
+ if (Directory.Exists(allFolder))
{
// Avoid implicitly captured closure
var currentRequest = request;
var path = BaseItem.SupportedImageExtensions
.Select(i => Path.Combine(allFolder, currentRequest.Name + i))
- .FirstOrDefault(_fileSystem.FileExists);
+ .FirstOrDefault(File.Exists);
if (!string.IsNullOrEmpty(path))
{
@@ -240,10 +240,10 @@ namespace MediaBrowser.Api.Images
{
var themeFolder = Path.Combine(_appPaths.MediaInfoImagesPath, request.Theme);
- if (_fileSystem.DirectoryExists(themeFolder))
+ if (Directory.Exists(themeFolder))
{
var path = BaseItem.SupportedImageExtensions.Select(i => Path.Combine(themeFolder, request.Name + i))
- .FirstOrDefault(_fileSystem.FileExists);
+ .FirstOrDefault(File.Exists);
if (!string.IsNullOrEmpty(path))
{
@@ -253,13 +253,13 @@ namespace MediaBrowser.Api.Images
var allFolder = Path.Combine(_appPaths.MediaInfoImagesPath, "all");
- if (_fileSystem.DirectoryExists(allFolder))
+ if (Directory.Exists(allFolder))
{
// Avoid implicitly captured closure
var currentRequest = request;
var path = BaseItem.SupportedImageExtensions.Select(i => Path.Combine(allFolder, currentRequest.Name + i))
- .FirstOrDefault(_fileSystem.FileExists);
+ .FirstOrDefault(File.Exists);
if (!string.IsNullOrEmpty(path))
{
diff --git a/MediaBrowser.Api/Images/RemoteImageService.cs b/MediaBrowser.Api/Images/RemoteImageService.cs
index 24c8ed835..24d4751c5 100644
--- a/MediaBrowser.Api/Images/RemoteImageService.cs
+++ b/MediaBrowser.Api/Images/RemoteImageService.cs
@@ -220,9 +220,9 @@ namespace MediaBrowser.Api.Images
try
{
- contentPath = _fileSystem.ReadAllText(pointerCachePath);
+ contentPath = File.ReadAllText(pointerCachePath);
- if (_fileSystem.FileExists(contentPath))
+ if (File.Exists(contentPath))
{
return await ResultFactory.GetStaticFileResult(Request, contentPath).ConfigureAwait(false);
}
@@ -239,7 +239,7 @@ namespace MediaBrowser.Api.Images
await DownloadImage(request.ImageUrl, urlHash, pointerCachePath).ConfigureAwait(false);
// Read the pointer file again
- contentPath = _fileSystem.ReadAllText(pointerCachePath);
+ contentPath = File.ReadAllText(pointerCachePath);
return await ResultFactory.GetStaticFileResult(Request, contentPath).ConfigureAwait(false);
}
@@ -264,7 +264,7 @@ namespace MediaBrowser.Api.Images
var fullCachePath = GetFullCachePath(urlHash + "." + ext);
- _fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(fullCachePath));
+ Directory.CreateDirectory(Path.GetDirectoryName(fullCachePath));
using (var stream = result.Content)
{
using (var filestream = _fileSystem.GetFileStream(fullCachePath, FileOpenMode.Create, FileAccessMode.Write, FileShareMode.Read, true))
@@ -273,8 +273,8 @@ namespace MediaBrowser.Api.Images
}
}
- _fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(pointerCachePath));
- _fileSystem.WriteAllText(pointerCachePath, fullCachePath);
+ Directory.CreateDirectory(Path.GetDirectoryName(pointerCachePath));
+ File.WriteAllText(pointerCachePath, fullCachePath);
}
}
diff --git a/MediaBrowser.Api/ItemLookupService.cs b/MediaBrowser.Api/ItemLookupService.cs
index 10d882e08..0e7bdc086 100644
--- a/MediaBrowser.Api/ItemLookupService.cs
+++ b/MediaBrowser.Api/ItemLookupService.cs
@@ -265,9 +265,9 @@ namespace MediaBrowser.Api
try
{
- contentPath = _fileSystem.ReadAllText(pointerCachePath);
+ contentPath = File.ReadAllText(pointerCachePath);
- if (_fileSystem.FileExists(contentPath))
+ if (File.Exists(contentPath))
{
return await ResultFactory.GetStaticFileResult(Request, contentPath).ConfigureAwait(false);
}
@@ -284,7 +284,7 @@ namespace MediaBrowser.Api
await DownloadImage(request.ProviderName, request.ImageUrl, urlHash, pointerCachePath).ConfigureAwait(false);
// Read the pointer file again
- contentPath = _fileSystem.ReadAllText(pointerCachePath);
+ contentPath = File.ReadAllText(pointerCachePath);
return await ResultFactory.GetStaticFileResult(Request, contentPath).ConfigureAwait(false);
}
@@ -305,7 +305,7 @@ namespace MediaBrowser.Api
var fullCachePath = GetFullCachePath(urlHash + "." + ext);
- _fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(fullCachePath));
+ Directory.CreateDirectory(Path.GetDirectoryName(fullCachePath));
using (var stream = result.Content)
{
using (var filestream = _fileSystem.GetFileStream(fullCachePath, FileOpenMode.Create, FileAccessMode.Write, FileShareMode.Read, true))
@@ -314,8 +314,8 @@ namespace MediaBrowser.Api
}
}
- _fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(pointerCachePath));
- _fileSystem.WriteAllText(pointerCachePath, fullCachePath);
+ Directory.CreateDirectory(Path.GetDirectoryName(pointerCachePath));
+ File.WriteAllText(pointerCachePath, fullCachePath);
}
/// <summary>
diff --git a/MediaBrowser.Api/Library/LibraryStructureService.cs b/MediaBrowser.Api/Library/LibraryStructureService.cs
index 3be6b29dd..d6bcf7878 100644
--- a/MediaBrowser.Api/Library/LibraryStructureService.cs
+++ b/MediaBrowser.Api/Library/LibraryStructureService.cs
@@ -255,12 +255,12 @@ namespace MediaBrowser.Api.Library
var currentPath = Path.Combine(rootFolderPath, request.Name);
var newPath = Path.Combine(rootFolderPath, request.NewName);
- if (!_fileSystem.DirectoryExists(currentPath))
+ if (!Directory.Exists(currentPath))
{
throw new FileNotFoundException("The media collection does not exist");
}
- if (!string.Equals(currentPath, newPath, StringComparison.OrdinalIgnoreCase) && _fileSystem.DirectoryExists(newPath))
+ if (!string.Equals(currentPath, newPath, StringComparison.OrdinalIgnoreCase) && Directory.Exists(newPath))
{
throw new ArgumentException("Media library already exists at " + newPath + ".");
}
@@ -273,11 +273,11 @@ namespace MediaBrowser.Api.Library
if (string.Equals(currentPath, newPath, StringComparison.OrdinalIgnoreCase))
{
var tempPath = Path.Combine(rootFolderPath, Guid.NewGuid().ToString("N"));
- _fileSystem.MoveDirectory(currentPath, tempPath);
+ Directory.Move(currentPath, tempPath);
currentPath = tempPath;
}
- _fileSystem.MoveDirectory(currentPath, newPath);
+ Directory.Move(currentPath, newPath);
}
finally
{
diff --git a/MediaBrowser.Api/Playback/BaseStreamingService.cs b/MediaBrowser.Api/Playback/BaseStreamingService.cs
index 9460dc523..ec42cad33 100644
--- a/MediaBrowser.Api/Playback/BaseStreamingService.cs
+++ b/MediaBrowser.Api/Playback/BaseStreamingService.cs
@@ -192,7 +192,7 @@ namespace MediaBrowser.Api.Playback
CancellationTokenSource cancellationTokenSource,
string workingDirectory = null)
{
- FileSystem.CreateDirectory(FileSystem.GetDirectoryName(outputPath));
+ Directory.CreateDirectory(Path.GetDirectoryName(outputPath));
await AcquireResources(state, cancellationTokenSource).ConfigureAwait(false);
@@ -258,7 +258,7 @@ namespace MediaBrowser.Api.Playback
}
var logFilePath = Path.Combine(ServerConfigurationManager.ApplicationPaths.LogDirectoryPath, logFilePrefix + "-" + Guid.NewGuid() + ".txt");
- FileSystem.CreateDirectory(FileSystem.GetDirectoryName(logFilePath));
+ Directory.CreateDirectory(Path.GetDirectoryName(logFilePath));
// FFMpeg writes debug/error info to stderr. This is useful when debugging so let's put it in the log directory.
state.LogFileStream = FileSystem.GetFileStream(logFilePath, FileOpenMode.Create, FileAccessMode.Write, FileShareMode.Read, true);
@@ -290,7 +290,7 @@ namespace MediaBrowser.Api.Playback
new JobLogger(Logger).StartStreamingLog(state, process.StandardError.BaseStream, state.LogFileStream);
// Wait for the file to exist before proceeeding
- while (!FileSystem.FileExists(state.WaitForPath ?? outputPath) && !transcodingJob.HasExited)
+ while (!File.Exists(state.WaitForPath ?? outputPath) && !transcodingJob.HasExited)
{
await Task.Delay(100, cancellationTokenSource.Token).ConfigureAwait(false);
}
diff --git a/MediaBrowser.Api/Playback/Hls/BaseHlsService.cs b/MediaBrowser.Api/Playback/Hls/BaseHlsService.cs
index 1e90d03b0..08a2183f8 100644
--- a/MediaBrowser.Api/Playback/Hls/BaseHlsService.cs
+++ b/MediaBrowser.Api/Playback/Hls/BaseHlsService.cs
@@ -83,13 +83,13 @@ namespace MediaBrowser.Api.Playback.Hls
TranscodingJob job = null;
var playlist = state.OutputFilePath;
- if (!FileSystem.FileExists(playlist))
+ if (!File.Exists(playlist))
{
var transcodingLock = ApiEntryPoint.Instance.GetTranscodingLock(playlist);
await transcodingLock.WaitAsync(cancellationTokenSource.Token).ConfigureAwait(false);
try
{
- if (!FileSystem.FileExists(playlist))
+ if (!File.Exists(playlist))
{
// If the playlist doesn't already exist, startup ffmpeg
try
@@ -264,7 +264,7 @@ namespace MediaBrowser.Api.Playback.Hls
var useGenericSegmenter = true;
if (useGenericSegmenter)
{
- var outputTsArg = Path.Combine(FileSystem.GetDirectoryName(outputPath), Path.GetFileNameWithoutExtension(outputPath)) + "%d" + GetSegmentFileExtension(state.Request);
+ var outputTsArg = Path.Combine(Path.GetDirectoryName(outputPath), Path.GetFileNameWithoutExtension(outputPath)) + "%d" + GetSegmentFileExtension(state.Request);
var timeDeltaParam = string.Empty;
diff --git a/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs b/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs
index b3099e17e..30696ec97 100644
--- a/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs
+++ b/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs
@@ -164,7 +164,7 @@ namespace MediaBrowser.Api.Playback.Hls
TranscodingJob job = null;
- if (FileSystem.FileExists(segmentPath))
+ if (File.Exists(segmentPath))
{
job = ApiEntryPoint.Instance.OnTranscodeBeginRequest(playlistPath, TranscodingJobType);
return await GetSegmentResult(state, playlistPath, segmentPath, segmentExtension, requestedIndex, job, cancellationToken).ConfigureAwait(false);
@@ -177,7 +177,7 @@ namespace MediaBrowser.Api.Playback.Hls
try
{
- if (FileSystem.FileExists(segmentPath))
+ if (File.Exists(segmentPath))
{
job = ApiEntryPoint.Instance.OnTranscodeBeginRequest(playlistPath, TranscodingJobType);
transcodingLock.Release();
@@ -381,7 +381,7 @@ namespace MediaBrowser.Api.Playback.Hls
private static FileSystemMetadata GetLastTranscodingFile(string playlist, string segmentExtension, IFileSystem fileSystem)
{
- var folder = fileSystem.GetDirectoryName(playlist);
+ var folder = Path.GetDirectoryName(playlist);
var filePrefix = Path.GetFileNameWithoutExtension(playlist) ?? string.Empty;
@@ -418,7 +418,7 @@ namespace MediaBrowser.Api.Playback.Hls
private string GetSegmentPath(StreamState state, string playlist, int index)
{
- var folder = FileSystem.GetDirectoryName(playlist);
+ var folder = Path.GetDirectoryName(playlist);
var filename = Path.GetFileNameWithoutExtension(playlist);
@@ -433,7 +433,7 @@ namespace MediaBrowser.Api.Playback.Hls
TranscodingJob transcodingJob,
CancellationToken cancellationToken)
{
- var segmentFileExists = FileSystem.FileExists(segmentPath);
+ var segmentFileExists = File.Exists(segmentPath);
// If all transcoding has completed, just return immediately
if (transcodingJob != null && transcodingJob.HasExited && segmentFileExists)
@@ -458,14 +458,14 @@ namespace MediaBrowser.Api.Playback.Hls
{
try
{
- var text = FileSystem.ReadAllText(playlistPath, Encoding.UTF8);
+ var text = File.ReadAllText(playlistPath, Encoding.UTF8);
// If it appears in the playlist, it's done
if (text.IndexOf(segmentFilename, StringComparison.OrdinalIgnoreCase) != -1)
{
if (!segmentFileExists)
{
- segmentFileExists = FileSystem.FileExists(segmentPath);
+ segmentFileExists = File.Exists(segmentPath);
}
if (segmentFileExists)
{
@@ -932,7 +932,7 @@ namespace MediaBrowser.Api.Playback.Hls
var mapArgs = state.IsOutputVideo ? EncodingHelper.GetMapArgs(state) : string.Empty;
- var outputTsArg = Path.Combine(FileSystem.GetDirectoryName(outputPath), Path.GetFileNameWithoutExtension(outputPath)) + "%d" + GetSegmentFileExtension(state.Request);
+ var outputTsArg = Path.Combine(Path.GetDirectoryName(outputPath), Path.GetFileNameWithoutExtension(outputPath)) + "%d" + GetSegmentFileExtension(state.Request);
var timeDeltaParam = string.Empty;
diff --git a/MediaBrowser.Api/Playback/Progressive/BaseProgressiveStreamingService.cs b/MediaBrowser.Api/Playback/Progressive/BaseProgressiveStreamingService.cs
index bb21fe5ae..621d1ff88 100644
--- a/MediaBrowser.Api/Playback/Progressive/BaseProgressiveStreamingService.cs
+++ b/MediaBrowser.Api/Playback/Progressive/BaseProgressiveStreamingService.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Globalization;
+using System.IO;
using System.Threading;
using System.Threading.Tasks;
using MediaBrowser.Common.Net;
@@ -153,7 +154,7 @@ namespace MediaBrowser.Api.Playback.Progressive
}
var outputPath = state.OutputFilePath;
- var outputPathExists = FileSystem.FileExists(outputPath);
+ var outputPathExists = File.Exists(outputPath);
var transcodingJob = ApiEntryPoint.Instance.GetTranscodingJob(outputPath, TranscodingJobType.Progressive);
var isTranscodeCached = outputPathExists && transcodingJob != null;
@@ -377,7 +378,7 @@ namespace MediaBrowser.Api.Playback.Progressive
{
TranscodingJob job;
- if (!FileSystem.FileExists(outputPath))
+ if (!File.Exists(outputPath))
{
job = await StartFfMpeg(state, outputPath, cancellationTokenSource).ConfigureAwait(false);
}
diff --git a/MediaBrowser.Api/PluginService.cs b/MediaBrowser.Api/PluginService.cs
index 94be45474..af61887b2 100644
--- a/MediaBrowser.Api/PluginService.cs
+++ b/MediaBrowser.Api/PluginService.cs
@@ -153,7 +153,11 @@ namespace MediaBrowser.Api
private readonly INetworkManager _network;
private readonly IDeviceManager _deviceManager;
- public PluginService(IJsonSerializer jsonSerializer, IApplicationHost appHost, IInstallationManager installationManager, INetworkManager network, IDeviceManager deviceManager)
+ public PluginService(IJsonSerializer jsonSerializer,
+ IApplicationHost appHost,
+ IInstallationManager installationManager,
+ INetworkManager network,
+ IDeviceManager deviceManager)
: base()
{
if (jsonSerializer == null)
@@ -173,7 +177,7 @@ namespace MediaBrowser.Api
/// </summary>
/// <param name="request">The request.</param>
/// <returns>System.Object.</returns>
- public async Task<object> Get(GetRegistrationStatus request)
+ public object Get(GetRegistrationStatus request)
{
var record = new MBRegistrationRecord
{
@@ -187,26 +191,12 @@ namespace MediaBrowser.Api
return ToOptimizedResult(record);
}
- //TODO this function is only kept for compatibility and should be removed once paid plugins break
- public async Task<object> Get(GetRegistration request)
- {
- var info = new RegistrationInfo
- {
- ExpirationDate = DateTime.Now.AddYears(100),
- IsRegistered = true,
- IsTrial = false,
- Name = request.Name
- };
-
- return ToOptimizedResult(info);
- }
-
/// <summary>
/// Gets the specified request.
/// </summary>
/// <param name="request">The request.</param>
/// <returns>System.Object.</returns>
- public async Task<object> Get(GetPlugins request)
+ public object Get(GetPlugins request)
{
var result = _appHost.Plugins.OrderBy(p => p.Name).Select(p => p.GetPluginInfo()).ToArray();
return ToOptimizedResult(result);
@@ -230,7 +220,7 @@ namespace MediaBrowser.Api
/// </summary>
/// <param name="request">The request.</param>
/// <returns>System.Object.</returns>
- public async Task<object> Get(GetPluginSecurityInfo request)
+ public object Get(GetPluginSecurityInfo request)
{
var result = new PluginSecurityInfo
{
diff --git a/MediaBrowser.Api/StartupWizardService.cs b/MediaBrowser.Api/StartupWizardService.cs
index 5f137d804..3d59b4c9a 100644
--- a/MediaBrowser.Api/StartupWizardService.cs
+++ b/MediaBrowser.Api/StartupWizardService.cs
@@ -102,7 +102,8 @@ namespace MediaBrowser.Api
return new StartupUser
{
Name = user.Name,
- ConnectUserName = user.ConnectUserName
+ ConnectUserName = user.ConnectUserName,
+ Password = user.Password
};
}
@@ -111,8 +112,13 @@ namespace MediaBrowser.Api
var user = _userManager.Users.First();
user.Name = request.Name;
+
_userManager.UpdateUser(user);
+ if (!string.IsNullOrEmpty(request.Password)) {
+ await _userManager.ChangePassword(user, request.Password).ConfigureAwait(false);
+ }
+
var result = new UpdateStartupUserResult();
return result;
@@ -130,6 +136,7 @@ namespace MediaBrowser.Api
{
public string Name { get; set; }
public string ConnectUserName { get; set; }
+ public string Password { get; set; }
}
public class UpdateStartupUserResult
diff --git a/MediaBrowser.Api/UserLibrary/PlaystateService.cs b/MediaBrowser.Api/UserLibrary/PlaystateService.cs
index 76f91e373..72a943092 100644
--- a/MediaBrowser.Api/UserLibrary/PlaystateService.cs
+++ b/MediaBrowser.Api/UserLibrary/PlaystateService.cs
@@ -267,13 +267,13 @@ namespace MediaBrowser.Api.UserLibrary
var session = GetSession(_sessionContext);
- var dto = await UpdatePlayedStatus(user, request.Id, true, datePlayed).ConfigureAwait(false);
+ var dto = UpdatePlayedStatus(user, request.Id, true, datePlayed);
foreach (var additionalUserInfo in session.AdditionalUsers)
{
var additionalUser = _userManager.GetUserById(additionalUserInfo.UserId);
- await UpdatePlayedStatus(additionalUser, request.Id, true, datePlayed).ConfigureAwait(false);
+ UpdatePlayedStatus(additionalUser, request.Id, true, datePlayed);
}
return dto;
@@ -412,13 +412,13 @@ namespace MediaBrowser.Api.UserLibrary
var session = GetSession(_sessionContext);
- var dto = await UpdatePlayedStatus(user, request.Id, false, null).ConfigureAwait(false);
+ var dto = UpdatePlayedStatus(user, request.Id, false, null);
foreach (var additionalUserInfo in session.AdditionalUsers)
{
var additionalUser = _userManager.GetUserById(additionalUserInfo.UserId);
- await UpdatePlayedStatus(additionalUser, request.Id, false, null).ConfigureAwait(false);
+ UpdatePlayedStatus(additionalUser, request.Id, false, null);
}
return dto;
@@ -432,7 +432,7 @@ namespace MediaBrowser.Api.UserLibrary
/// <param name="wasPlayed">if set to <c>true</c> [was played].</param>
/// <param name="datePlayed">The date played.</param>
/// <returns>Task.</returns>
- private async Task<UserItemDataDto> UpdatePlayedStatus(User user, string itemId, bool wasPlayed, DateTime? datePlayed)
+ private UserItemDataDto UpdatePlayedStatus(User user, string itemId, bool wasPlayed, DateTime? datePlayed)
{
var item = _libraryManager.GetItemById(itemId);