Browse Source

add api endpoint to empty trash (#1988)

pull/1990/head
Jason Dove 4 months ago committed by GitHub
parent
commit
100ae0adda
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 5
      CHANGELOG.md
  2. 26
      ErsatzTV/Controllers/Api/MaintenanceController.cs

5
CHANGELOG.md

@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
## [Unreleased] ## [Unreleased]
### Added
- Add `linux-musl-x64` artifact for users running Alpine x64
- Add API endpoint to empty trash (POST to `/api/maintenance/empty_trash`)
- e.g. `curl -XPOST -d '' http://localhost:8409/api/maintenance/empty_trash`
### Fixed ### Fixed
- Fix error message about synchronizing Plex collections from a Plex server that has zero collections - Fix error message about synchronizing Plex collections from a Plex server that has zero collections

26
ErsatzTV/Controllers/Api/MaintenanceController.cs

@ -1,20 +1,34 @@
using ErsatzTV.Application.Maintenance; using ErsatzTV.Application.Maintenance;
using ErsatzTV.Core;
using MediatR; using MediatR;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
namespace ErsatzTV.Controllers.Api; namespace ErsatzTV.Controllers.Api;
[ApiController] [ApiController]
public class MaintenanceController public class MaintenanceController(IMediator mediator)
{ {
private readonly IMediator _mediator;
public MaintenanceController(IMediator mediator) => _mediator = mediator;
[HttpGet("/api/maintenance/gc")] [HttpGet("/api/maintenance/gc")]
public async Task<IActionResult> GarbageCollection([FromQuery] bool force = false) public async Task<IActionResult> GarbageCollection([FromQuery] bool force = false)
{ {
await _mediator.Send(new ReleaseMemory(force)); await mediator.Send(new ReleaseMemory(force));
return new OkResult();
}
[HttpPost("/api/maintenance/empty_trash")]
public async Task<IActionResult> EmptyTrash()
{
Either<BaseError, Unit> result = await mediator.Send(new EmptyTrash());
foreach (BaseError error in result.LeftToSeq())
{
return new ContentResult
{
StatusCode = StatusCodes.Status500InternalServerError,
Content = error.ToString(),
ContentType = "text/plain"
};
}
return new OkResult(); return new OkResult();
} }
} }

Loading…
Cancel
Save