diff --git a/.changes/unreleased/DX-20250902-215127.yaml b/.changes/unreleased/DX-20250902-215127.yaml new file mode 100644 index 000000000..7d682d3ec --- /dev/null +++ b/.changes/unreleased/DX-20250902-215127.yaml @@ -0,0 +1,7 @@ +kind: DX +body: | + Improve error message when a stored object cannot be written on local disk +time: 2025-09-02T21:51:27.248966834+02:00 +custom: + Issue: "" + SchemaChange: No schema change diff --git a/src/Bundle/ChillDocStoreBundle/AsyncUpload/Driver/LocalStorage/StoredObjectManager.php b/src/Bundle/ChillDocStoreBundle/AsyncUpload/Driver/LocalStorage/StoredObjectManager.php index 09d277635..9174f42e6 100644 --- a/src/Bundle/ChillDocStoreBundle/AsyncUpload/Driver/LocalStorage/StoredObjectManager.php +++ b/src/Bundle/ChillDocStoreBundle/AsyncUpload/Driver/LocalStorage/StoredObjectManager.php @@ -18,6 +18,7 @@ use Chill\DocStoreBundle\Exception\StoredObjectManagerException; use Chill\DocStoreBundle\Service\Cryptography\KeyGenerator; use Chill\DocStoreBundle\Service\StoredObjectManagerInterface; use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; +use Symfony\Component\Filesystem\Exception\IOExceptionInterface; use Symfony\Component\Filesystem\Filesystem; use Symfony\Component\Filesystem\Path; @@ -147,16 +148,11 @@ class StoredObjectManager implements StoredObjectManagerInterface public function writeContent(string $filename, string $encryptedContent): void { $fullPath = $this->buildPath($filename); - $dir = Path::getDirectory($fullPath); - if (!$this->filesystem->exists($dir)) { - $this->filesystem->mkdir($dir); - } - - $result = file_put_contents($fullPath, $encryptedContent); - - if (false === $result) { - throw StoredObjectManagerException::unableToStoreDocumentOnDisk(); + try { + $this->filesystem->dumpFile($fullPath, $encryptedContent); + } catch (IOExceptionInterface $exception) { + throw StoredObjectManagerException::unableToStoreDocumentOnDisk($exception); } }