|
@@ -47,14 +47,15 @@ class LocalStorage implements FileStorageInterface
|
|
|
protected FilesystemInterface $filesystem;
|
|
protected FilesystemInterface $filesystem;
|
|
|
|
|
|
|
|
public function __construct(
|
|
public function __construct(
|
|
|
- protected readonly FilesystemMap $filesystemMap,
|
|
|
|
|
|
|
+ protected readonly FilesystemMap $filesystemMap,
|
|
|
protected readonly EntityManagerInterface $entityManager,
|
|
protected readonly EntityManagerInterface $entityManager,
|
|
|
- protected readonly AccessRepository $accessRepository,
|
|
|
|
|
- protected readonly DataManager $dataManager,
|
|
|
|
|
- protected readonly CacheManager $cacheManager,
|
|
|
|
|
- protected readonly ImageFactory $imageFactory,
|
|
|
|
|
- protected readonly FileUtils $fileUtils,
|
|
|
|
|
- protected readonly UrlBuilder $urlBuilder
|
|
|
|
|
|
|
+ protected readonly AccessRepository $accessRepository,
|
|
|
|
|
+ protected readonly DataManager $dataManager,
|
|
|
|
|
+ protected readonly CacheManager $cacheManager,
|
|
|
|
|
+ protected readonly ImageFactory $imageFactory,
|
|
|
|
|
+ protected readonly FileUtils $fileUtils,
|
|
|
|
|
+ protected readonly UrlBuilder $urlBuilder,
|
|
|
|
|
+ protected readonly string $fileStorageDir
|
|
|
) {
|
|
) {
|
|
|
$this->filesystem = $filesystemMap->get(static::FS_KEY);
|
|
$this->filesystem = $filesystemMap->get(static::FS_KEY);
|
|
|
}
|
|
}
|
|
@@ -300,10 +301,10 @@ class LocalStorage implements FileStorageInterface
|
|
|
* @param int $organizationId
|
|
* @param int $organizationId
|
|
|
* @return void
|
|
* @return void
|
|
|
*/
|
|
*/
|
|
|
- public function removeOrganizationDirectory(int $organizationId): void
|
|
|
|
|
|
|
+ public function deleteOrganizationFiles(int $organizationId): void
|
|
|
{
|
|
{
|
|
|
- $this->filesystem->delete('organization/' . $organizationId);
|
|
|
|
|
- $this->filesystem->delete('temp/organization/' . $organizationId);
|
|
|
|
|
|
|
+ $this->rrmDir('organization/' . $organizationId);
|
|
|
|
|
+ $this->rrmDir('temp/organization/' . $organizationId);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -312,10 +313,27 @@ class LocalStorage implements FileStorageInterface
|
|
|
* @param int $personId
|
|
* @param int $personId
|
|
|
* @return void
|
|
* @return void
|
|
|
*/
|
|
*/
|
|
|
- public function removePersonDirectory(int $personId): void
|
|
|
|
|
|
|
+ public function deletePersonFiles(int $personId): void
|
|
|
{
|
|
{
|
|
|
- $this->filesystem->delete('person/' . $personId);
|
|
|
|
|
- $this->filesystem->delete('temp/person/' . $personId);
|
|
|
|
|
|
|
+ $this->rrmDir('person/' . $personId);
|
|
|
|
|
+ $this->rrmDir('temp/person/' . $personId);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * Supprime récursivement un répertoire
|
|
|
|
|
+ *
|
|
|
|
|
+ * (Au moment du développement, Gaufrette ne permet pas la suppression de répertoire, on laissera
|
|
|
|
|
+ * le soin à un cron de supprimer les répertoires vides du storage)
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param string $dirKey
|
|
|
|
|
+ * @return void
|
|
|
|
|
+ */
|
|
|
|
|
+ protected function rrmDir(string $dirKey): void {
|
|
|
|
|
+ if (!$this->filesystem->isDirectory($dirKey)) {
|
|
|
|
|
+ throw new \RuntimeException('Directory `'.$dirKey.'` does not exist');
|
|
|
|
|
+ }
|
|
|
|
|
+ $dir = Path::join($this->fileStorageDir, $dirKey);
|
|
|
|
|
+ Path::rmtree($dir);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|