From 0f73d31b1923d660883c51455d9354120207a892 Mon Sep 17 00:00:00 2001 From: Mats Mikkel Rummelhoff Date: Sat, 4 Jun 2022 14:38:25 +0200 Subject: [PATCH 1/3] Prevent hidden folders in volumes from being indexed by the Asset Indexes utility --- src/services/AssetIndexer.php | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/services/AssetIndexer.php b/src/services/AssetIndexer.php index b84277ff1eb..2e36957d692 100644 --- a/src/services/AssetIndexer.php +++ b/src/services/AssetIndexer.php @@ -50,19 +50,19 @@ */ class AssetIndexer extends Component { + /** * Returns a sorted list of files on a volume. * * @param Volume $volume The Volume to perform indexing on. * @param string $directory Optional path to get index list on a subfolder. * @return Generator - * @throws FsException */ public function getIndexListOnVolume(Volume $volume, string $directory = ''): Generator { try { $fileList = $volume->getFs()->getFileList($directory); - } catch (VolumeException $exception) { + } catch (InvalidConfigException|FsException $exception) { Craft::$app->getErrorHandler()->logException($exception); return; } @@ -165,14 +165,9 @@ public function startIndexingSession(array $volumes, bool $cacheRemoteImages = t /** @var Volume $volume */ foreach ($volumeList as $volume) { - try { - $fileList = $volume->getFs()->getFileList(); - } catch (FsException) { - Craft::warning('Unable to list files in ' . $volume->handle . '.'); - continue; + if ($fileList = $this->getIndexListOnVolume($volume)) { + $total += $this->storeIndexList($fileList, $session->id, (int)$volume->id); } - - $total += $this->storeIndexList($fileList, $session->id, (int)$volume->id); } $session->totalEntries = $total; From af8d7664492b79b6bfaa0fee4ff62e663127f974 Mon Sep 17 00:00:00 2001 From: Mats Mikkel Rummelhoff Date: Sat, 4 Jun 2022 14:52:39 +0200 Subject: [PATCH 2/3] ECS --- src/services/AssetIndexer.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/services/AssetIndexer.php b/src/services/AssetIndexer.php index 2e36957d692..6cc1b853e4e 100644 --- a/src/services/AssetIndexer.php +++ b/src/services/AssetIndexer.php @@ -50,7 +50,6 @@ */ class AssetIndexer extends Component { - /** * Returns a sorted list of files on a volume. * From 1d442bc54cb69f0609c6d715593e93f46dae7854 Mon Sep 17 00:00:00 2001 From: Mats Mikkel Rummelhoff Date: Sat, 4 Jun 2022 14:59:32 +0200 Subject: [PATCH 3/3] Remove redundant if statement --- src/services/AssetIndexer.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/services/AssetIndexer.php b/src/services/AssetIndexer.php index 6cc1b853e4e..bf3a1eebd43 100644 --- a/src/services/AssetIndexer.php +++ b/src/services/AssetIndexer.php @@ -164,9 +164,8 @@ public function startIndexingSession(array $volumes, bool $cacheRemoteImages = t /** @var Volume $volume */ foreach ($volumeList as $volume) { - if ($fileList = $this->getIndexListOnVolume($volume)) { - $total += $this->storeIndexList($fileList, $session->id, (int)$volume->id); - } + $fileList = $this->getIndexListOnVolume($volume); + $total += $this->storeIndexList($fileList, $session->id, (int)$volume->id); } $session->totalEntries = $total;