Skip to content

Commit c5a12fd

Browse files
author
Mathis Koblin
committed
Aborting delete of processed file if identifier or storage are empty #5
1 parent 8963124 commit c5a12fd

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

Classes/Command/UnduplicateCommand.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ class UnduplicateCommand extends Command
9696
private $metadataHandler;
9797

9898
public function __construct(
99-
private readonly ConnectionPool $connectionPool,
99+
private readonly ConnectionPool $connectionPool,
100100
private readonly StorageRepository $storageRepository
101101
)
102102
{
@@ -609,10 +609,17 @@ private function findAndDeleteOldProcessedFile(int $oldFileUid): void
609609

610610
private function deleteProcessedFile(mixed $identifier, int $storageId): void
611611
{
612+
if (empty($identifier) || empty($storageId)) {
613+
$this->output->writeln('<error>Empty identifier or storage id. Aborting delete of processed file</error>');
614+
return;
615+
}
616+
612617
$storage = $this->storageRepository->getStorageObject($storageId);
613618
$storagePath = Environment::getPublicPath() . DIRECTORY_SEPARATOR . $storage->getRootLevelFolder()->getPublicUrl();
614619
$file = rtrim($storagePath, '/') . $identifier;
620+
615621
$this->output->writeln('<info>Deleting processed file ' . $file . '</info>');
622+
616623
if (file_exists($file)) {
617624
unlink($file);
618625
// delete all empty parent folders

0 commit comments

Comments
 (0)