From 7ab299951d22d891390aaa0f890a3a4259d8b0fd Mon Sep 17 00:00:00 2001 From: Oliver Stark Date: Thu, 8 Apr 2021 18:51:13 +0200 Subject: [PATCH] fix volume check --- CHANGELOG.md | 4 ++++ src/Actions/InfoAction.php | 3 +-- src/Actions/VolumesDownAction.php | 9 +++++++-- src/Actions/VolumesUpAction.php | 10 ++++++++-- 4 files changed, 20 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7a039d5..6eb713e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 1.0.4 - 2021-04-08 +- Don't throw exception if no local volumes exist +- Remove DB_TABLE_PREFIX check + ## 1.0.3 - 2021-01-11 - Fixed type issue with symfony/process 5.x (use `Process::fromShellCommandline()`) diff --git a/src/Actions/InfoAction.php b/src/Actions/InfoAction.php index 2f9f4bb..4f12f6c 100644 --- a/src/Actions/InfoAction.php +++ b/src/Actions/InfoAction.php @@ -74,7 +74,6 @@ public function run() $this->envRow('SECURITY_KEY', null, true), new TableSeparator(), - $this->envRow('DB_TABLE_PREFIX'), $this->envRow('DB_SERVER', function ($local, $remote) { return stristr($remote, '.frbit.com'); }), @@ -103,7 +102,7 @@ public function run() ); // Error message with more instructions - $errors = array_filter(['SECURITY_KEY', 'DB_TABLE_PREFIX'], function ($key) { + $errors = array_filter(['SECURITY_KEY'], function ($key) { return ! self::assertEquals( $this->remoteInfo[$key], getenv($key) diff --git a/src/Actions/VolumesDownAction.php b/src/Actions/VolumesDownAction.php index ad5e976..5d84f97 100644 --- a/src/Actions/VolumesDownAction.php +++ b/src/Actions/VolumesDownAction.php @@ -57,8 +57,13 @@ public function run(?string $stage = null, ?array $volumeHandles = null) return ExitCode::UNSPECIFIED_ERROR; } - $volumes = $this->localVolume->filterByHandle($volumeHandles); - $lastVolume = end($volumes); + try { + $volumes = $this->localVolume->filterByHandle($volumeHandles); + $lastVolume = end($volumes); + } catch (VolumeNotFound $exception) { + $this->line('No local volumes found.' . PHP_EOL); + return ExitCode::OK; + } foreach ($volumes as $volume) { $path = $this->prepareForRsync($volume->path); diff --git a/src/Actions/VolumesUpAction.php b/src/Actions/VolumesUpAction.php index 1f3d9e5..bed375e 100644 --- a/src/Actions/VolumesUpAction.php +++ b/src/Actions/VolumesUpAction.php @@ -57,8 +57,14 @@ public function run(?string $stage = null, ?array $volumeHandles = null) return ExitCode::UNSPECIFIED_ERROR; } - $volumes = $this->localVolume->filterByHandle($volumeHandles); - $lastVolume = end($volumes); + try { + $volumes = $this->localVolume->filterByHandle($volumeHandles); + $lastVolume = end($volumes); + } catch (VolumeNotFound $exception) { + $this->line('No local volumes found.' . PHP_EOL); + return ExitCode::OK; + } + foreach ($volumes as $volume) { $path = $this->prepareForRsync($volume->path);