From 2cb64de316e4e7fac3494e2c0d762cfb0e31f59f Mon Sep 17 00:00:00 2001 From: Phan An Date: Fri, 10 Dec 2021 16:22:35 +0100 Subject: [PATCH] feat: rename koel:tidy to koel:prune --- app/Console/Commands/PruneLibraryCommand.php | 18 ++++++++++++++++++ app/Console/Commands/TidyLibraryCommand.php | 17 ++--------------- .../{TidyLibrary.php => PruneLibrary.php} | 2 +- app/Providers/EventServiceProvider.php | 4 ++-- app/Services/MediaSyncService.php | 2 +- 5 files changed, 24 insertions(+), 19 deletions(-) create mode 100644 app/Console/Commands/PruneLibraryCommand.php rename app/Listeners/{TidyLibrary.php => PruneLibrary.php} (94%) diff --git a/app/Console/Commands/PruneLibraryCommand.php b/app/Console/Commands/PruneLibraryCommand.php new file mode 100644 index 00000000..86fcf66d --- /dev/null +++ b/app/Console/Commands/PruneLibraryCommand.php @@ -0,0 +1,18 @@ +info('Empty artists and albums removed.'); + } +} diff --git a/app/Console/Commands/TidyLibraryCommand.php b/app/Console/Commands/TidyLibraryCommand.php index da56c802..b854d190 100644 --- a/app/Console/Commands/TidyLibraryCommand.php +++ b/app/Console/Commands/TidyLibraryCommand.php @@ -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.'); } } diff --git a/app/Listeners/TidyLibrary.php b/app/Listeners/PruneLibrary.php similarity index 94% rename from app/Listeners/TidyLibrary.php rename to app/Listeners/PruneLibrary.php index 05a23204..f1c60138 100644 --- a/app/Listeners/TidyLibrary.php +++ b/app/Listeners/PruneLibrary.php @@ -4,7 +4,7 @@ namespace App\Listeners; use App\Services\MediaSyncService; -class TidyLibrary +class PruneLibrary { private MediaSyncService $mediaSyncService; diff --git a/app/Providers/EventServiceProvider.php b/app/Providers/EventServiceProvider.php index 979cfa9e..0d38af02 100644 --- a/app/Providers/EventServiceProvider.php +++ b/app/Providers/EventServiceProvider.php @@ -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, ], diff --git a/app/Services/MediaSyncService.php b/app/Services/MediaSyncService.php index 9d45abcb..7d5b2f91 100644 --- a/app/Services/MediaSyncService.php +++ b/app/Services/MediaSyncService.php @@ -187,7 +187,7 @@ class MediaSyncService } } - public function tidy(): void + public function prune(): void { $inUseAlbums = $this->albumRepository->getNonEmptyAlbumIds(); $inUseAlbums[] = Album::UNKNOWN_ID;