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