From a641db07643c83b3f394984fa003663a93eaae0f Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Mon, 27 May 2019 20:03:19 -0600 Subject: [PATCH] Update avatar deletion --- app/Jobs/DeletePipeline/DeleteAccountPipeline.php | 11 ----------- app/Observers/AvatarObserver.php | 8 +++++++- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/app/Jobs/DeletePipeline/DeleteAccountPipeline.php b/app/Jobs/DeletePipeline/DeleteAccountPipeline.php index bcb02fe99..ba265379d 100644 --- a/app/Jobs/DeletePipeline/DeleteAccountPipeline.php +++ b/app/Jobs/DeletePipeline/DeleteAccountPipeline.php @@ -74,17 +74,6 @@ class DeleteAccountPipeline implements ShouldQueue if($user->profile) { $avatar = $user->profile->avatar; - if(is_file($avatar->media_path)) { - if($avatar->media_path != 'public/avatars/default.png') { - unlink($avatar->media_path); - } - } - - if(is_file($avatar->thumb_path)) { - if($avatar->thumb_path != 'public/avatars/default.png') { - unlink($avatar->thumb_path); - } - } $avatar->forceDelete(); } diff --git a/app/Observers/AvatarObserver.php b/app/Observers/AvatarObserver.php index cdc2faa12..c8fef1a10 100644 --- a/app/Observers/AvatarObserver.php +++ b/app/Observers/AvatarObserver.php @@ -48,7 +48,13 @@ class AvatarObserver public function deleting(Avatar $avatar) { $path = storage_path('app/'.$avatar->media_path); - @unlink($path); + if(is_file($path) && $avatar->media_path != 'public/avatars/default.png') { + @unlink($path); + } + $path = storage_path('app/'.$avatar->thumb_path); + if(is_file($path) && $avatar->thumb_path != 'public/avatars/default.png') { + @unlink($path); + } } /**