mirror of
https://github.com/zeropingheroes/lancache-autofill
synced 2024-09-20 05:11:52 +00:00
Remove download directory after download complete to conserve disk space
This commit is contained in:
parent
201effcee6
commit
c44a3d5703
1 changed files with 19 additions and 1 deletions
|
@ -5,6 +5,7 @@ namespace Zeropingheroes\LancacheAutofill\Commands\Steam;
|
|||
use Illuminate\Console\Command;
|
||||
use Illuminate\Database\Capsule\Manager as Capsule;
|
||||
use Symfony\Component\Process\Exception\ProcessFailedException;
|
||||
use Symfony\Component\Process\Process;
|
||||
use Zeropingheroes\LancacheAutofill\Services\SteamCmd\SteamCmd;
|
||||
|
||||
class StartDownloading extends Command
|
||||
|
@ -47,10 +48,13 @@ class StartDownloading extends Command
|
|||
$this->info('Starting download of '.$item->app_id.' for '.$item->platform.' from Steam account '.$account);
|
||||
|
||||
try {
|
||||
|
||||
$downloadPath = getenv('DOWNLOADS_DIRECTORY').'/'.$item->platform.'/'.$item->app_id;
|
||||
|
||||
$steamCmd = (new SteamCmd(getenv('STEAMCMD_PATH')))
|
||||
->login($account)
|
||||
->platform($item->platform)
|
||||
->directory(getenv('DOWNLOADS_DIRECTORY').'/'.$item->platform.'/'.$item->app_id)
|
||||
->directory($downloadPath)
|
||||
->update($item->app_id)
|
||||
->run();
|
||||
|
||||
|
@ -66,6 +70,20 @@ class StartDownloading extends Command
|
|||
$this->info('Successfully completed download of '.$item->app_id.' for '.$item->platform.' from Steam account '.$account);
|
||||
$this->updateQueueItemStatus($item->id, 'completed');
|
||||
|
||||
// Delete download directory
|
||||
$this->info('Deleting '.$item->app_id.' from disk');
|
||||
$remove = new Process('rm -rf '.$downloadPath);
|
||||
$remove->run(function ($type, $buffer) {
|
||||
|
||||
if (Process::ERR === $type) {
|
||||
$this->error(str_replace(["\r", "\n"], '', $buffer));
|
||||
}
|
||||
else {
|
||||
$this->line(str_replace(["\r", "\n"], '', $buffer));
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
// As the download was successful, do not attempt to download using any other Steam accounts
|
||||
break;
|
||||
|
||||
|
|
Loading…
Reference in a new issue