feat: rename koel:tidy to koel:prune

This commit is contained in:
Phan An 2021-12-10 16:22:35 +01:00
parent 1e93645cbb
commit 2cb64de316
No known key found for this signature in database
GPG key ID: A81E4477F0BB6FDC
5 changed files with 24 additions and 19 deletions

View file

@ -0,0 +1,18 @@
<?php
namespace App\Console\Commands;
use App\Events\LibraryChanged;
use Illuminate\Console\Command;
class PruneLibraryCommand extends Command
{
protected $signature = 'koel:prune';
protected $description = 'Remove empty artists and albums';
public function handle(): void
{
event(new LibraryChanged());
$this->info('Empty artists and albums removed.');
}
}

View file

@ -2,28 +2,15 @@
namespace App\Console\Commands;
use App\Events\LibraryChanged;
use App\Services\MediaSyncService;
use Illuminate\Console\Command;
class TidyLibraryCommand extends Command
{
protected $signature = 'koel:tidy';
protected $description = 'Tidy up the library by deleting empty artists and albums';
private MediaSyncService $mediaSyncService;
public function __construct(MediaSyncService $mediaSyncService)
{
parent::__construct();
$this->mediaSyncService = $mediaSyncService;
}
protected $hidden = true;
public function handle(): void
{
$this->mediaSyncService->tidy();
event(new LibraryChanged());
$this->info('Empty artists and albums removed.');
$this->warn('koel:tidy has been renamed. Use koel:prune instead.');
}
}

View file

@ -4,7 +4,7 @@ namespace App\Listeners;
use App\Services\MediaSyncService;
class TidyLibrary
class PruneLibrary
{
private MediaSyncService $mediaSyncService;

View file

@ -17,7 +17,7 @@ use App\Listeners\DownloadAlbumCover;
use App\Listeners\DownloadArtistImage;
use App\Listeners\LoveMultipleTracksOnLastfm;
use App\Listeners\LoveTrackOnLastfm;
use App\Listeners\TidyLibrary;
use App\Listeners\PruneLibrary;
use App\Listeners\UnloveMultipleTracksOnLastfm;
use App\Listeners\UpdateLastfmNowPlaying;
use App\Models\Album;
@ -46,7 +46,7 @@ class EventServiceProvider extends ServiceProvider
],
LibraryChanged::class => [
TidyLibrary::class,
PruneLibrary::class,
ClearMediaCache::class,
],

View file

@ -187,7 +187,7 @@ class MediaSyncService
}
}
public function tidy(): void
public function prune(): void
{
$inUseAlbums = $this->albumRepository->getNonEmptyAlbumIds();
$inUseAlbums[] = Album::UNKNOWN_ID;