Refactor PostgreSQL provider: multi-schema & async prep
- Refactor migrations and provider to use multiple PostgreSQL schemas, each matching a legacy SQLite database (activitylog, authentication, displaypreferences, library, users). - All tables, foreign keys, and indexes are now schema-qualified; Down migration drops tables by schema. - Provider ensures schemas exist before migrations; entities are mapped to correct schemas in OnModelCreating. - Add support for max-pool-size, min-pool-size, and multiplexing connection options; update logging accordingly. - VACUUM ANALYZE now runs per schema during scheduled optimization. - TruncateAllTablesAsync now truncates tables with schema qualification. - README updated with schema structure, new options, and multiplexing warnings. - CacheDecorator now calls async repository methods using .GetAwaiter().GetResult(), with documentation. - Lays groundwork for full async/await and multiplexing support in the database layer.
This commit is contained in:
@@ -29,9 +29,9 @@ public class KeyframeManager : IKeyframeManager
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public IReadOnlyList<KeyframeData> GetKeyframeData(Guid itemId)
|
||||
public async Task<IReadOnlyList<KeyframeData>> GetKeyframeDataAsync(Guid itemId, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return _repository.GetKeyframeData(itemId);
|
||||
return await _repository.GetKeyframeDataAsync(itemId, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
||||
@@ -103,7 +103,23 @@ namespace Emby.Server.Implementations.Library
|
||||
|
||||
public IReadOnlyList<MediaStream> GetMediaStreams(MediaStreamQuery query)
|
||||
{
|
||||
var list = _mediaStreamRepository.GetMediaStreams(query);
|
||||
var list = _mediaStreamRepository.GetMediaStreamsAsync(query, CancellationToken.None)
|
||||
.GetAwaiter()
|
||||
.GetResult();
|
||||
|
||||
foreach (var stream in list)
|
||||
{
|
||||
stream.SupportsExternalStream = StreamSupportsExternalStream(stream);
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
public async Task<IReadOnlyList<MediaStream>> GetMediaStreamsAsync(MediaStreamQuery query, CancellationToken cancellationToken = default)
|
||||
{
|
||||
var list = await _mediaStreamRepository
|
||||
.GetMediaStreamsAsync(query, cancellationToken)
|
||||
.ConfigureAwait(false);
|
||||
|
||||
foreach (var stream in list)
|
||||
{
|
||||
@@ -143,6 +159,32 @@ namespace Emby.Server.Implementations.Library
|
||||
return GetMediaStreamsForItem(list);
|
||||
}
|
||||
|
||||
public async Task<IReadOnlyList<MediaStream>> GetMediaStreamsAsync(Guid itemId, CancellationToken cancellationToken = default)
|
||||
{
|
||||
var list = await GetMediaStreamsAsync(
|
||||
new MediaStreamQuery { ItemId = itemId },
|
||||
cancellationToken)
|
||||
.ConfigureAwait(false);
|
||||
|
||||
return GetMediaStreamsForItem(list);
|
||||
}
|
||||
|
||||
public IReadOnlyList<MediaAttachment> GetMediaAttachments(MediaAttachmentQuery query)
|
||||
{
|
||||
return _mediaAttachmentRepository
|
||||
.GetMediaAttachmentsAsync(query, CancellationToken.None)
|
||||
.GetAwaiter()
|
||||
.GetResult();
|
||||
}
|
||||
|
||||
public IReadOnlyList<MediaAttachment> GetMediaAttachments(Guid itemId)
|
||||
{
|
||||
return GetMediaAttachments(new MediaAttachmentQuery
|
||||
{
|
||||
ItemId = itemId
|
||||
});
|
||||
}
|
||||
|
||||
private IReadOnlyList<MediaStream> GetMediaStreamsForItem(IReadOnlyList<MediaStream> streams)
|
||||
{
|
||||
foreach (var stream in streams)
|
||||
@@ -157,18 +199,24 @@ namespace Emby.Server.Implementations.Library
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public IReadOnlyList<MediaAttachment> GetMediaAttachments(MediaAttachmentQuery query)
|
||||
public async Task<IReadOnlyList<MediaAttachment>> GetMediaAttachmentsAsync(
|
||||
MediaAttachmentQuery query,
|
||||
CancellationToken cancellationToken = default)
|
||||
{
|
||||
return _mediaAttachmentRepository.GetMediaAttachments(query);
|
||||
return await _mediaAttachmentRepository
|
||||
.GetMediaAttachmentsAsync(query, cancellationToken)
|
||||
.ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public IReadOnlyList<MediaAttachment> GetMediaAttachments(Guid itemId)
|
||||
public async Task<IReadOnlyList<MediaAttachment>> GetMediaAttachmentsAsync(
|
||||
Guid itemId,
|
||||
CancellationToken cancellationToken = default)
|
||||
{
|
||||
return GetMediaAttachments(new MediaAttachmentQuery
|
||||
{
|
||||
ItemId = itemId
|
||||
});
|
||||
return await GetMediaAttachmentsAsync(
|
||||
new MediaAttachmentQuery { ItemId = itemId },
|
||||
cancellationToken)
|
||||
.ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task<IReadOnlyList<MediaSourceInfo>> GetPlaybackMediaSources(BaseItem item, User user, bool allowMediaProbe, bool enablePathSubstitution, CancellationToken cancellationToken)
|
||||
|
||||
Reference in New Issue
Block a user