Merge pull request #11836 from snipe/fixes/500_if_image_is_missing

Fixed 500 error if uploaded file is missing from asset view
This commit is contained in:
snipe 2022-09-15 16:21:13 -07:00 committed by GitHub
commit 0f777b3168
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1198,10 +1198,14 @@
@endif @endif
</td> </td>
<td> <td>
@if (Storage::exists('private_uploads/assets/'.$file->filename))
{{ $file->filename }} {{ $file->filename }}
@else
<del>{{ $file->filename }}</del>
@endif
</td> </td>
<td data-value="{{ @Storage::size('private_uploads/assets/'.$file->filename) }}"> <td data-value="{{ (Storage::exists('private_uploads/assets/'.$file->filename) ? Storage::size('private_uploads/assets/'.$file->filename) : '') }}">
{{ @Helper::formatFilesizeUnits(Storage::size('private_uploads/assets/'.$file->filename)) }} {{ @Helper::formatFilesizeUnits(Storage::exists('private_uploads/assets/'.$file->filename) ? Storage::size('private_uploads/assets/'.$file->filename) : '') }}
</td> </td>
<td> <td>
@if ($file->note) @if ($file->note)
@ -1209,7 +1213,7 @@
@endif @endif
</td> </td>
<td> <td>
@if ($file->filename) @if (($file->filename) && (Storage::exists('private_uploads/assets/'.$file->filename)))
<a href="{{ route('show/assetfile', [$asset->id, $file->id]) }}" class="btn btn-default"> <a href="{{ route('show/assetfile', [$asset->id, $file->id]) }}" class="btn btn-default">
<i class="fas fa-download" aria-hidden="true"></i> <i class="fas fa-download" aria-hidden="true"></i>
</a> </a>
@ -1291,10 +1295,14 @@
@endif @endif
</td> </td>
<td> <td>
{{ $file->filename }} @if (Storage::exists('private_uploads/assetmodels/'.$file->filename))
{{ $file->filename }}
@else
<del>{{ $file->filename }}</del>
@endif
</td> </td>
<td data-value="{{ Storage::size('private_uploads/assetmodels/'.$file->filename) }}"> <td data-value="{{ (Storage::exists('private_uploads/assetmodels/'.$file->filename) ? Storage::size('private_uploads/assetmodels/'.$file->filename) : '') }}">
{{ Helper::formatFilesizeUnits(Storage::size('private_uploads/assetmodels/'.$file->filename)) }} {{ Helper::formatFilesizeUnits(@Storage::size('private_uploads/assetmodels/'.$file->filename)) }}
</td> </td>
<td> <td>
@if ($file->note) @if ($file->note)
@ -1302,7 +1310,7 @@
@endif @endif
</td> </td>
<td> <td>
@if ($file->filename) @if (($file->filename) && (Storage::exists('private_uploads/assetmodels/'.$file->filename)))
<a href="{{ route('show/modelfile', [$asset->model->id, $file->id]) }}" class="btn btn-default"> <a href="{{ route('show/modelfile', [$asset->model->id, $file->id]) }}" class="btn btn-default">
<i class="fas fa-download" aria-hidden="true"></i> <i class="fas fa-download" aria-hidden="true"></i>
</a> </a>