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); + } } /**