From 88fea0c78e4e54c29207b03d11ad34e82cb979d8 Mon Sep 17 00:00:00 2001 From: Adam Malone Date: Sun, 15 Mar 2020 20:14:34 +1100 Subject: [PATCH] Fixes #46 - detects if no backups have been returned and escapes. --- src/Commands/DbBackupCommand.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Commands/DbBackupCommand.php b/src/Commands/DbBackupCommand.php index 86f33a4..2f8d22b 100644 --- a/src/Commands/DbBackupCommand.php +++ b/src/Commands/DbBackupCommand.php @@ -174,12 +174,14 @@ public function dbBackupDownload( if (!$opts['backup']) { $client->addQuery('sort', '-created'); $client->addQuery('limit', 1); - $backup = $databaseBackupsAdapter->getAll($environment->uuid, $dbName); + $backups = $databaseBackupsAdapter->getAll($environment->uuid, $dbName); $client->clearQuery(); - if (empty($backup)) { + + if (!$backups->count()) { throw new \Exception('Unable to find a database backup to download.'); } - $backupId = $backup[0]->id; + + $backupId = $backups[0]->id; } else { $backupId = $opts['backup']; }