mirror of
https://github.com/Poniverse/Pony.fm.git
synced 2024-11-22 13:07:59 +01:00
Fix options and imports for commands
This commit is contained in:
parent
683aa568e9
commit
43c45adece
2 changed files with 14 additions and 8 deletions
|
@ -34,8 +34,8 @@ class ClearTrackCache extends Command
|
|||
* @var string
|
||||
*/
|
||||
protected $signature = 'track-cache:clear
|
||||
[--tracks=expired : Clear only [expired] (default) or [all] cached tracks.]
|
||||
[--force : Skip all prompts.]';
|
||||
{--tracks=expired : Clear only [expired] (default) or [all] cached tracks.}
|
||||
{--force : Skip all prompts.}';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
|
|
|
@ -20,20 +20,25 @@
|
|||
|
||||
namespace Poniverse\Ponyfm\Console\Commands;
|
||||
|
||||
use File;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Foundation\Bus\DispatchesJobs;
|
||||
use Poniverse\Ponyfm\Jobs\EncodeTrackFile;
|
||||
use Poniverse\Ponyfm\Track;
|
||||
use Poniverse\Ponyfm\TrackFile;
|
||||
use Symfony\Component\HttpFoundation\File\File;
|
||||
|
||||
class RebuildTrackCache extends Command
|
||||
{
|
||||
|
||||
use DispatchesJobs;
|
||||
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'track-cache:rebuild
|
||||
[--force : Skip all prompts.]';
|
||||
{--force : Skip all prompts.}';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
|
@ -186,18 +191,19 @@ class RebuildTrackCache extends Command
|
|||
$trackFiles = TrackFile::where('is_cacheable', false)->get();
|
||||
|
||||
// Record the above files which do not exist (i.e., have not been encoded yet)
|
||||
$trackFileIds = [];
|
||||
$emptyTrackFiles = [];
|
||||
$count = 0;
|
||||
foreach ($trackFiles as $trackFile) {
|
||||
if (!File::exists($trackFile->getFile())) {
|
||||
$count++;
|
||||
$trackFileIds[] = $trackFile->id;
|
||||
$emptyTrackFiles[] = $trackFile;
|
||||
}
|
||||
}
|
||||
|
||||
// Encode recorded files
|
||||
$encodeTrackFileCommand = new EncodeTrackFileCommand($trackFileIds);
|
||||
$encodeTrackFileCommand->execute();
|
||||
foreach($emptyTrackFiles as $emptyTrackFile) {
|
||||
$this->dispatch(new EncodeTrackFile($emptyTrackFile, false));
|
||||
}
|
||||
|
||||
$this->info($count . ' tracks encoded.');
|
||||
|
||||
|
|
Loading…
Reference in a new issue