|
|
|
@ -194,7 +194,9 @@ namespace MediaBrowser.Common.Implementations.Updates
|
|
|
|
|
/// <returns>Task{List{PackageInfo}}.</returns>
|
|
|
|
|
public async Task<IEnumerable<PackageInfo>> GetAvailablePackagesWithoutRegistrationInfo(CancellationToken cancellationToken)
|
|
|
|
|
{
|
|
|
|
|
using (var stream = await GetCachedPackages(cancellationToken).ConfigureAwait(false))
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
using (var stream = _fileSystem.OpenRead(PackageCachePath))
|
|
|
|
|
{
|
|
|
|
|
var packages = _jsonSerializer.DeserializeFromStream<List<PackageInfo>>(stream).ToList();
|
|
|
|
|
|
|
|
|
@ -206,25 +208,22 @@ namespace MediaBrowser.Common.Implementations.Updates
|
|
|
|
|
return packages;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private string PackageCachePath
|
|
|
|
|
catch (Exception)
|
|
|
|
|
{
|
|
|
|
|
get { return Path.Combine(_appPaths.CachePath, "serverpackages.json"); }
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private async Task<Stream> GetCachedPackages(CancellationToken cancellationToken)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
_lastPackageUpdateTime = DateTime.MinValue;
|
|
|
|
|
await UpdateCachedPackages(cancellationToken, true).ConfigureAwait(false);
|
|
|
|
|
using (var stream = _fileSystem.OpenRead(PackageCachePath))
|
|
|
|
|
{
|
|
|
|
|
return _fileSystem.OpenRead(PackageCachePath);
|
|
|
|
|
return _jsonSerializer.DeserializeFromStream<List<PackageInfo>>(stream).ToList();
|
|
|
|
|
}
|
|
|
|
|
catch (Exception)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
await UpdateCachedPackages(cancellationToken, true).ConfigureAwait(false);
|
|
|
|
|
return _fileSystem.OpenRead(PackageCachePath);
|
|
|
|
|
private string PackageCachePath
|
|
|
|
|
{
|
|
|
|
|
get { return Path.Combine(_appPaths.CachePath, "serverpackages.json"); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private readonly SemaphoreSlim _updateSemaphore = new SemaphoreSlim(1, 1);
|
|
|
|
|