Added requeue command for retrying failed downloads

This commit is contained in:
ilumos 2017-08-17 07:56:31 +01:00
parent 8761a9098d
commit 5d1c7c70f6
3 changed files with 69 additions and 1 deletions

View file

@ -71,6 +71,11 @@ Clear the temporary download location:
* Optionally specify any combination of app ID, platform, account and status
* Calling with no arguments clears the queue
`steam:requeue [status=failed]`
* Requeue failed and/or completed items in the download queue.
* By default failed items are requeued
`steam:search-apps name`
* Search Steam apps by name.

View file

@ -7,7 +7,7 @@ use Illuminate\Events\Dispatcher;
use Illuminate\Database\Capsule\Manager as Capsule;
use Dotenv\Dotenv;
use Zeropingheroes\LancacheAutofill\Console\Commands\Steam\{UpdateAppList, SearchApps, QueueApp, ShowQueue, Dequeue, AuthoriseAccount, StartDownloading};
use Zeropingheroes\LancacheAutofill\Console\Commands\Steam\{UpdateAppList, SearchApps, QueueApp, ShowQueue, Dequeue, Requeue, AuthoriseAccount, StartDownloading};
use Zeropingheroes\LancacheAutofill\Console\Commands\{InitialiseDatabase, InitialiseDownloadsDirectory};
// Load Composer's autoloader
@ -46,6 +46,7 @@ $app->add(new SearchApps);
$app->add(new QueueApp);
$app->add(new ShowQueue);
$app->add(new Dequeue);
$app->add(new Requeue);
$app->add(new AuthoriseAccount);
$app->add(new StartDownloading);

View file

@ -0,0 +1,62 @@
<?php
namespace Zeropingheroes\LancacheAutofill\Console\Commands\Steam;
use Illuminate\Console\Command;
use Illuminate\Database\Capsule\Manager as Capsule;
class Requeue extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'steam:requeue
{status=failed}';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Requeue failed and/or completed item(s) in the download queue';
/**
* The permissible statuses.
*
* @var array
*/
const STATUSES = ['queued', 'completed', 'failed'];
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
if( $this->argument('status') && ! in_array($this->argument('status'), $this::STATUSES))
{
$this->error('Invalid status specified. Available statuses are: '. implode(' ', $this::STATUSES));
die();
}
$query = Capsule::table('steam_queue')
->where('status','<>','queued');
if( $this->argument('status') )
$query->where('status', $this->argument('status'));
$affected = $query->update([
'status' => 'queued',
'message' => null,
]);
if( ! $affected ) {
$this->error('No items in the queue match the provided criteria');
die();
}
$this->info('Requeued ' . $affected .' item(s) in the download queue');
}
}