mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-09 08:14:59 +00:00
Merge branch 'improve-local-storage' into 'master'
Improve error handling when saving objects to local disk See merge request Chill-Projet/chill-bundles!872
This commit is contained in:
7
.changes/unreleased/DX-20250902-215127.yaml
Normal file
7
.changes/unreleased/DX-20250902-215127.yaml
Normal file
@@ -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
|
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user