summaryrefslogtreecommitdiff
path: root/app/Http/RequestHandlers/CleanDataFolder.php
diff options
context:
space:
mode:
authorGreg Roach <fisharebest@gmail.com>2021-03-15 14:05:33 +0000
committerGreg Roach <fisharebest@gmail.com>2021-03-15 15:09:52 +0000
commitf0448b68d9ccb96d481d0f989b8bf9901c324b04 (patch)
treefb39d85245dd7396ade50ce07e20763f83316c1d /app/Http/RequestHandlers/CleanDataFolder.php
parenta2221dfbfbf1dfbb322e14294e5387499e722805 (diff)
downloadwebtrees-f0448b68d9ccb96d481d0f989b8bf9901c324b04.tar.gz
webtrees-f0448b68d9ccb96d481d0f989b8bf9901c324b04.tar.bz2
webtrees-f0448b68d9ccb96d481d0f989b8bf9901c324b04.zip
Filesystem error handling
Diffstat (limited to 'app/Http/RequestHandlers/CleanDataFolder.php')
-rw-r--r--app/Http/RequestHandlers/CleanDataFolder.php21
1 files changed, 14 insertions, 7 deletions
diff --git a/app/Http/RequestHandlers/CleanDataFolder.php b/app/Http/RequestHandlers/CleanDataFolder.php
index b3e0c9bb1d..4a0ae7ca7c 100644
--- a/app/Http/RequestHandlers/CleanDataFolder.php
+++ b/app/Http/RequestHandlers/CleanDataFolder.php
@@ -24,6 +24,7 @@ use Fisharebest\Webtrees\I18N;
use Fisharebest\Webtrees\Registry;
use Fisharebest\Webtrees\Services\TreeService;
use League\Flysystem\Filesystem;
+use League\Flysystem\FilesystemException;
use League\Flysystem\StorageAttributes;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
@@ -82,14 +83,20 @@ class CleanDataFolder implements RequestHandlerInterface
}
// List the top-level contents of the data folder
- $entries = $data_filesystem->listContents('', Filesystem::LIST_SHALLOW)
- ->map(static function (StorageAttributes $attributes): string {
- if ($attributes->isDir()) {
- return $attributes->path() . '/';
- }
+ try {
+ $entries = $data_filesystem->listContents('', Filesystem::LIST_SHALLOW)
+ ->map(static function (StorageAttributes $attributes): string {
+ if ($attributes->isDir()) {
+ return $attributes->path() . '/';
+ }
+
+ return $attributes->path();
+ })
+ ->toArray();
+ } catch (FilesystemException $ex) {
+ $entries = [];
+ }
- return $attributes->path();
- });
return $this->viewResponse('admin/clean-data', [
'title' => I18N::translate('Clean up data folder'),