Private
Public Access
1
0

chg: dev: the user's avatar will be saved as a uuid.extension #4
All checks were successful
Deploy to Production / deploy (push) Successful in 10s

This commit is contained in:
2026-04-14 16:53:16 +02:00
parent 15ba26ccf2
commit 5d6aff8d90

View File

@@ -19,6 +19,7 @@ use Liip\ImagineBundle\Imagine\Cache\CacheManager;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\DependencyInjection\Attribute\Autowire;
use Symfony\Component\HttpFoundation\File\UploadedFile;
use Symfony\Component\Uid\Uuid;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
@@ -228,16 +229,14 @@ class ProfileController extends AbstractController
}
$ext = $file->guessExtension() ?? 'jpg';
$newPath = sprintf('avatar/%d.%s', $user->getId(), $ext);
$newPath = sprintf('avatar/%s.%s', Uuid::v4()->toRfc4122(), $ext);
$oldPath = $user->getAvatarPath();
// Remove old file and any cached thumbnails
if ($oldPath) {
if ($oldPath !== $newPath) {
try {
$mediaStorage->delete($oldPath);
} catch (\Throwable) {
}
try {
$mediaStorage->delete($oldPath);
} catch (\Throwable) {
}
$cacheManager->remove($oldPath, 'avatar_thumb');
}