mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 14:11:10 +00:00
Adds book deletion and restore to the web client.
Soft deletes books so the scan keeps their paths reserved, lists the deleted books on a themed page, and lets the user restore them. Updates the API, bundled themes, localization, documentation and tests. Closes #213
This commit is contained in:
1 parent
ef5ede6325
commit
f26b07d4ff
125 files changed
+9856
-378
No files matched your search
+11
@@ -212,6 +212,17 @@ public class BookEntity : IStorageEntity, IAuditableEntity
|
||||
/// </summary>
|
||||
public List<BookRatingEntity> Ratings { get; set; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether the book was deleted by the user and is waiting to be restored or permanently removed.
|
||||
/// A deleted book is kept out of every catalogue read and is not materialized again by scans, so that an automatic scan never undoes the deletion.
|
||||
/// </summary>
|
||||
public bool IsDeleted { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the date and time when the book was deleted, or <see langword="null"/> when the book is not deleted.
|
||||
/// </summary>
|
||||
public DateTime? DeletedOnUtc { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the status of the metadata enrichment of the book.
|
||||
/// </summary>
|
||||
|
||||
@@ -26,15 +26,53 @@ public interface IBookRepository : IRepository<BookEntity>,
|
||||
/// <summary>
|
||||
/// Gets the book of the media library identified by <paramref name="libraryId"/> that is stored at the provided <paramref name="path"/>.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Soft deleted books are included on purpose, so that the scan deletion strategy can permanently remove a deleted book when its file disappears from disk.
|
||||
/// </remarks>
|
||||
/// <param name="libraryId">The Id of the media library whose book is retrieved.</param>
|
||||
/// <param name="path">The file system path of the book to be retrieved.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
/// <returns>An <see cref="Result{TValue}"/> containing either the <see cref="BookEntity"/> stored at the provided path, or an error.</returns>
|
||||
Task<Result<BookEntity?>> GetByPathAsync(Guid libraryId, string path, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the soft deleted book identified by <paramref name="id"/>.
|
||||
/// </summary>
|
||||
/// <param name="id">The Id of the soft deleted book to get.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
/// <returns>An <see cref="Result{TValue}"/> containing either the soft deleted <see cref="BookEntity"/>, <see langword="null"/> when the book does not exist or is not soft deleted, or an error.</returns>
|
||||
Task<Result<BookEntity?>> GetSoftDeletedByIdAsync(Guid id, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the soft deleted books of the media library identified by <paramref name="libraryId"/>.
|
||||
/// </summary>
|
||||
/// <param name="libraryId">The Id of the media library whose soft deleted books are retrieved.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
/// <returns>An <see cref="Result{TValue}"/> containing either the soft deleted books, or an error.</returns>
|
||||
Task<Result<IReadOnlyList<BookEntity>>> GetSoftDeletedByLibraryIdAsync(Guid libraryId, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Soft deletes the book identified by <paramref name="id"/>, without removing its stored metadata or artwork.
|
||||
/// </summary>
|
||||
/// <param name="id">The Id of the book to soft delete.</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>
|
||||
Task<Result<Updated>> SoftDeleteByIdAsync(Guid id, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Restores the soft deleted book identified by <paramref name="id"/>.
|
||||
/// </summary>
|
||||
/// <param name="id">The Id of the book to restore.</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>
|
||||
Task<Result<Updated>> RestoreSoftDeletedByIdAsync(Guid id, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the subset of <paramref name="paths"/> that is already used by a book of the library identified by <paramref name="libraryId"/>.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Soft deleted books are included on purpose: their paths must still count as taken, so that a scan never materializes a deleted book again.
|
||||
/// </remarks>
|
||||
/// <param name="libraryId">The Id of the library whose books are searched.</param>
|
||||
/// <param name="paths">The book paths to check.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
@@ -83,6 +121,9 @@ public interface IBookRepository : IRepository<BookEntity>,
|
||||
/// Resets the enrichment state of the books stored at the provided <paramref name="paths"/> in the media library identified by
|
||||
/// <paramref name="libraryId"/>, so that they are re-enriched, because their content changed since the last scan.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Soft deleted books are included on purpose: if such a book is restored after its content changed, it must be re-enriched instead of keeping stale metadata.
|
||||
/// </remarks>
|
||||
/// <param name="libraryId">The Id of the media library whose books are reset.</param>
|
||||
/// <param name="paths">The file system paths of the books whose enrichment state is reset.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
@@ -93,6 +134,9 @@ public interface IBookRepository : IRepository<BookEntity>,
|
||||
/// Resets the metadata enrichment status of all the books of the media library identified by <paramref name="libraryId"/>,
|
||||
/// so that they are re-enriched, because the metadata provider configuration of the library changed.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Soft deleted books are included on purpose: if such a book is restored after the provider configuration changed, it must be re-enriched with the new providers.
|
||||
/// </remarks>
|
||||
/// <param name="libraryId">The Id of the media library whose books are reset.</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>
|
||||
@@ -102,6 +146,9 @@ public interface IBookRepository : IRepository<BookEntity>,
|
||||
/// Resets the artwork status of all the artwork of the books of the media library identified by <paramref name="libraryId"/>,
|
||||
/// so that they are re-resolved, because the artwork provider configuration of the library changed.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Soft deleted books are included on purpose: if such a book is restored after the provider configuration changed, its artwork must be re-resolved with the new providers.
|
||||
/// </remarks>
|
||||
/// <param name="libraryId">The Id of the media library whose artwork is reset.</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>
|
||||
|
||||
+19
@@ -258,6 +258,25 @@ public static class BookEntityMapping
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts a deleted <paramref name="repositoryEntity"/> to <see cref="DeletedBookResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="repositoryEntity">The deleted repository entity to be converted.</param>
|
||||
/// <param name="deletedOnUtc">The date and time when the book was deleted.</param>
|
||||
/// <returns>The converted deleted book response.</returns>
|
||||
public static DeletedBookResponse ToResponse(this BookEntity repositoryEntity, DateTime deletedOnUtc)
|
||||
{
|
||||
return new DeletedBookResponse(
|
||||
repositoryEntity.Id,
|
||||
repositoryEntity.LibraryId,
|
||||
repositoryEntity.Title,
|
||||
repositoryEntity.OriginalTitle,
|
||||
repositoryEntity.Path,
|
||||
deletedOnUtc,
|
||||
repositoryEntity.Artwork.FirstOrDefault(artwork => artwork.ArtworkType == ArtworkType.Cover)?.FileName
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts <paramref name="repositoryEntities"/> to a collection of <see cref="Book"/>.
|
||||
/// </summary>
|
||||
|
||||
Reference in new issue
Block a user