From 0c08125c12ef3933c05086fddb931de1b5433b37 Mon Sep 17 00:00:00 2001 From: Paragon Initiative Enterprises Date: Wed, 8 May 2024 11:43:44 -0400 Subject: [PATCH] Distinct error message if data directory is empty --- src/Fetch.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Fetch.php b/src/Fetch.php index bf5f692..36a9377 100644 --- a/src/Fetch.php +++ b/src/Fetch.php @@ -81,10 +81,12 @@ public function getLatestBundle($checkEd25519Signature = null, $checkChronicle = $checkChronicle = (bool) (static::CHECK_CHRONICLE_BY_DEFAULT && $sodiumCompatIsntSlow); } - /** @var int $bundleIndex */ $bundleIndex = 0; - /** @var Bundle $bundle */ - foreach ($this->listBundles('', $this->trustChannel) as $bundle) { + $bundlesAvailable = $this->listBundles('', $this->trustChannel); + if (empty($bundlesAvailable)) { + throw new BundleException('No bundles were found in the data directory.'); + } + foreach ($bundlesAvailable as $bundle) { if ($bundle->hasCustom()) { $validator = $bundle->getValidator(); } else {