mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 01:11:10 +00:00
Adds metadata and artwork provider configuration seeding
Seeds a disabled provider configuration for every loaded plugin supporting a library type, so that libraries list the metadata and artwork providers they can use. Configurations are seeded on startup, on library creation, and reconciled when the library type changes, and are removed only when a library or a plugin is deleted. Reads the library metadata providers through the new provider configuration store.
This commit is contained in:
1 parent
9ae8c0c394
commit
00dcf3d471
20 files changed
+1139
-27
No files matched your search
+51
@@ -77,4 +77,55 @@ internal sealed class ArtworkProviderConfigurationRepository : IArtworkProviderC
|
||||
}
|
||||
return Result.Updated;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deletes all the artwork provider configurations of the media library identified by <paramref name="libraryId"/>.
|
||||
/// </summary>
|
||||
/// <param name="libraryId">The Id of the media library whose artwork provider configurations are deleted.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
/// <returns>An <see cref="Result{TValue}"/> representing either a successful operation, or an error.</returns>
|
||||
public async Task<Result<Deleted>> DeleteByLibraryIdAsync(Guid libraryId, CancellationToken cancellationToken)
|
||||
{
|
||||
List<LibraryArtworkProviderConfigurationEntity> configurations = await _luminaDbContext.LibraryArtworkProviderConfigurations
|
||||
.Where(configuration => configuration.LibraryId == libraryId)
|
||||
.ToListAsync(cancellationToken).ConfigureAwait(false);
|
||||
if (configurations.Count > 0)
|
||||
_luminaDbContext.LibraryArtworkProviderConfigurations.RemoveRange(configurations);
|
||||
return Result.Deleted;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deletes all the artwork provider configurations referencing the plugin identified by <paramref name="pluginId"/>.
|
||||
/// </summary>
|
||||
/// <param name="pluginId">The Id of the plugin whose artwork provider configurations are deleted.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
/// <returns>An <see cref="Result{TValue}"/> representing either a successful operation, or an error.</returns>
|
||||
public async Task<Result<Deleted>> DeleteByPluginIdAsync(Guid pluginId, CancellationToken cancellationToken)
|
||||
{
|
||||
List<LibraryArtworkProviderConfigurationEntity> configurations = await _luminaDbContext.LibraryArtworkProviderConfigurations
|
||||
.Where(configuration => configuration.PluginId == pluginId)
|
||||
.ToListAsync(cancellationToken).ConfigureAwait(false);
|
||||
if (configurations.Count > 0)
|
||||
_luminaDbContext.LibraryArtworkProviderConfigurations.RemoveRange(configurations);
|
||||
return Result.Deleted;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deletes the artwork provider configurations of the media library identified by <paramref name="libraryId"/> that reference
|
||||
/// one of the plugins identified by <paramref name="pluginIds"/>.
|
||||
/// </summary>
|
||||
/// <param name="libraryId">The Id of the media library whose artwork provider configurations are deleted.</param>
|
||||
/// <param name="pluginIds">The Ids of the plugins whose configurations of the media library are deleted.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
/// <returns>An <see cref="Result{TValue}"/> representing either a successful operation, or an error.</returns>
|
||||
public async Task<Result<Deleted>> DeleteByLibraryIdAndPluginIdsAsync(Guid libraryId, IEnumerable<Guid> pluginIds, CancellationToken cancellationToken)
|
||||
{
|
||||
List<Guid> pluginIdList = [.. pluginIds];
|
||||
List<LibraryArtworkProviderConfigurationEntity> configurations = await _luminaDbContext.LibraryArtworkProviderConfigurations
|
||||
.Where(configuration => configuration.LibraryId == libraryId && pluginIdList.Contains(configuration.PluginId))
|
||||
.ToListAsync(cancellationToken).ConfigureAwait(false);
|
||||
if (configurations.Count > 0)
|
||||
_luminaDbContext.LibraryArtworkProviderConfigurations.RemoveRange(configurations);
|
||||
return Result.Deleted;
|
||||
}
|
||||
}
|
||||
+51
@@ -77,4 +77,55 @@ internal sealed class LibraryMetadataProviderConfigurationRepository : ILibraryM
|
||||
}
|
||||
return Result.Updated;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deletes all the metadata provider configurations of the media library identified by <paramref name="libraryId"/>.
|
||||
/// </summary>
|
||||
/// <param name="libraryId">The Id of the media library whose metadata provider configurations are deleted.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
/// <returns>An <see cref="Result{TValue}"/> representing either a successful operation, or an error.</returns>
|
||||
public async Task<Result<Deleted>> DeleteByLibraryIdAsync(Guid libraryId, CancellationToken cancellationToken)
|
||||
{
|
||||
List<LibraryMetadataProviderConfigurationEntity> configurations = await _luminaDbContext.LibraryMetadataProviderConfigurations
|
||||
.Where(configuration => configuration.LibraryId == libraryId)
|
||||
.ToListAsync(cancellationToken).ConfigureAwait(false);
|
||||
if (configurations.Count > 0)
|
||||
_luminaDbContext.LibraryMetadataProviderConfigurations.RemoveRange(configurations);
|
||||
return Result.Deleted;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deletes all the metadata provider configurations referencing the plugin identified by <paramref name="pluginId"/>.
|
||||
/// </summary>
|
||||
/// <param name="pluginId">The Id of the plugin whose metadata provider configurations are deleted.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
/// <returns>An <see cref="Result{TValue}"/> representing either a successful operation, or an error.</returns>
|
||||
public async Task<Result<Deleted>> DeleteByPluginIdAsync(Guid pluginId, CancellationToken cancellationToken)
|
||||
{
|
||||
List<LibraryMetadataProviderConfigurationEntity> configurations = await _luminaDbContext.LibraryMetadataProviderConfigurations
|
||||
.Where(configuration => configuration.PluginId == pluginId)
|
||||
.ToListAsync(cancellationToken).ConfigureAwait(false);
|
||||
if (configurations.Count > 0)
|
||||
_luminaDbContext.LibraryMetadataProviderConfigurations.RemoveRange(configurations);
|
||||
return Result.Deleted;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deletes the metadata provider configurations of the media library identified by <paramref name="libraryId"/> that reference
|
||||
/// one of the plugins identified by <paramref name="pluginIds"/>.
|
||||
/// </summary>
|
||||
/// <param name="libraryId">The Id of the media library whose metadata provider configurations are deleted.</param>
|
||||
/// <param name="pluginIds">The Ids of the plugins whose configurations of the media library are deleted.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
/// <returns>An <see cref="Result{TValue}"/> representing either a successful operation, or an error.</returns>
|
||||
public async Task<Result<Deleted>> DeleteByLibraryIdAndPluginIdsAsync(Guid libraryId, IEnumerable<Guid> pluginIds, CancellationToken cancellationToken)
|
||||
{
|
||||
List<Guid> pluginIdList = [.. pluginIds];
|
||||
List<LibraryMetadataProviderConfigurationEntity> configurations = await _luminaDbContext.LibraryMetadataProviderConfigurations
|
||||
.Where(configuration => configuration.LibraryId == libraryId && pluginIdList.Contains(configuration.PluginId))
|
||||
.ToListAsync(cancellationToken).ConfigureAwait(false);
|
||||
if (configurations.Count > 0)
|
||||
_luminaDbContext.LibraryMetadataProviderConfigurations.RemoveRange(configurations);
|
||||
return Result.Deleted;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user