From 8ddbc2fb88c45f29a61ddbb76b4381410e5c5916 Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Mon, 6 Sep 2021 15:18:48 +0200 Subject: [PATCH] Handle missing target folder on import --- Classes/Service/DestinationDataImportService.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Classes/Service/DestinationDataImportService.php b/Classes/Service/DestinationDataImportService.php index 7c72bf4..520c717 100644 --- a/Classes/Service/DestinationDataImportService.php +++ b/Classes/Service/DestinationDataImportService.php @@ -7,6 +7,7 @@ use TYPO3\CMS\Core\DataHandling\DataHandler; use TYPO3\CMS\Core\DataHandling\SlugHelper; use TYPO3\CMS\Core\Database\ConnectionPool; use TYPO3\CMS\Core\Log\LogManager; +use TYPO3\CMS\Core\Resource\Exception\FolderDoesNotExistException; use TYPO3\CMS\Core\Resource\FileRepository; use TYPO3\CMS\Core\Resource\Index\MetaDataRepository; use TYPO3\CMS\Core\Resource\ResourceFactory; @@ -656,7 +657,14 @@ class DestinationDataImportService if ($file = $this->loadFile($orgFileUrl)) { // Move file to defined folder $this->logger->info('Adding file ' . $file); - $this->storage->addFile($this->environment->getPublicPath() . "/uploads/tx_events/" . $file, $this->storage->getFolder($this->filesFolder)); + + try { + $targetFolder = $this->storage->getFolder($this->filesFolder); + } catch (FolderDoesNotExistException $e) { + $targetFolder = $this->storage->createFolder($this->filesFolder); + } + + $this->storage->addFile($this->environment->getPublicPath() . "/uploads/tx_events/" . $file, $targetFolder); } else { $error = true; }