Merge pull request #12454 from snipe/fixes/fixed_500_when_userfile_does_not_exisy

Handle missing userfiles more gracefully
This commit is contained in:
snipe 2023-02-02 11:08:54 -08:00 committed by GitHub
commit 2d3318feb6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 8 deletions

View file

@ -390,7 +390,8 @@ return [
'start_date' => 'Start Date',
'end_date' => 'End Date',
'alt_uploaded_image_thumbnail' => 'Uploaded thumbnail',
'placeholder_kit' => 'Select a kit'
'placeholder_kit' => 'Select a kit',
'file_not_found' => 'File not found',

View file

@ -869,16 +869,19 @@
</td>
<td>
@if ($file->filename)
@if ( Helper::checkUploadIsImage($file->get_src('users')))
@if ((Storage::exists('private_uploads/users/'.$file->filename)) && ( Helper::checkUploadIsImage($file->get_src('users'))))
<a href="{{ route('show/userfile', ['userId' => $user->id, 'fileId' => $file->id, 'download' => 'false']) }}" data-toggle="lightbox" data-type="image"><img src="{{ route('show/userfile', ['userId' => $user->id, 'fileId' => $file->id]) }}" class="img-thumbnail" style="max-width: 50px;"></a>
@else
<i class="fa fa-times text-danger" aria-hidden="true"></i>
{{ trans('general.file_not_found') }}
@endif
@endif
</td>
<td>
{{ $file->filename }}
</td>
<td>
{{ Helper::formatFilesizeUnits(Storage::size('private_uploads/users/'.$file->filename)) }}
<td data-value="{{ (Storage::exists('private_uploads/users/'.$file->filename)) ? Storage::size('private_uploads/users/'.$file->filename) : '' }}">
{{ (Storage::exists('private_uploads/users/'.$file->filename)) ? Helper::formatFilesizeUnits(Storage::size('private_uploads/users/'.$file->filename)) : '' }}
</td>
<td>
@ -888,10 +891,12 @@
</td>
<td>
@if ($file->filename)
<a href="{{ route('show/userfile', [$user->id, $file->id]) }}" class="btn btn-default">
<i class="fas fa-download" aria-hidden="true"></i>
<span class="sr-only">{{ trans('general.download') }}</span>
</a>
@if ((Storage::exists('private_uploads/users/'.$file->filename)) && ( Helper::checkUploadIsImage($file->get_src('users'))))
<a href="{{ route('show/userfile', [$user->id, $file->id]) }}" class="btn btn-default">
<i class="fas fa-download" aria-hidden="true"></i>
<span class="sr-only">{{ trans('general.download') }}</span>
</a>
@endif
@endif
</td>
<td>{{ $file->created_at }}</td>