Skip to content

Commit

Permalink
Merge pull request #48 from Oksydan/erease-file-fix
Browse files Browse the repository at this point in the history
File erase fix for every possible format
  • Loading branch information
Oksydan authored Jan 6, 2024
2 parents e3ce6f1 + 0395c02 commit 3d121d1
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions src/Handler/FileEraser.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,32 @@ public function remove(string $fileName): bool
$result = unlink($fullFilePath);
}

return $result;
$result = $result && $this->removeWebpFile($fileName);

return $result && $this->removeAvifFile($fileName);
}

private function removeWebpFile(string $fileName): bool
{
$webpFileName = pathinfo($fileName, PATHINFO_FILENAME) . '.webp';
$fullFilePath = $this->imagesDir . $webpFileName;

if (file_exists($fullFilePath)) {
return unlink($fullFilePath);
}

return true;
}

public function getTargetDirectory()
private function removeAvifFile(string $fileName): bool
{
return $this->imagesDir;
$avifFileName = pathinfo($fileName, PATHINFO_FILENAME) . '.avif';
$fullFilePath = $this->imagesDir . $avifFileName;

if (file_exists($fullFilePath)) {
return unlink($fullFilePath);
}

return true;
}
}

0 comments on commit 3d121d1

Please sign in to comment.