From 78fb2b223962314943f5fb35af3f8712a0f761a6 Mon Sep 17 00:00:00 2001 From: snipe Date: Fri, 24 May 2019 15:28:53 -0700 Subject: [PATCH] Only build the log upload destination path if there is a matching record Fixes [ch1232] --- app/Http/Controllers/AssetFilesController.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/app/Http/Controllers/AssetFilesController.php b/app/Http/Controllers/AssetFilesController.php index aca7429415..4ce67fc84a 100644 --- a/app/Http/Controllers/AssetFilesController.php +++ b/app/Http/Controllers/AssetFilesController.php @@ -111,12 +111,16 @@ class AssetFilesController extends Controller $this->authorize('update', $asset); $log = Actionlog::find($fileId); - $full_filename = $destinationPath.'/'.$log->filename; - if (file_exists($full_filename)) { - unlink($destinationPath.'/'.$log->filename); + if ($log) { + $full_filename = $destinationPath.'/'.$log->filename; + if (file_exists($full_filename)) { + unlink($destinationPath.'/'.$log->filename); + } + $log->delete(); + return redirect()->back()->with('success', trans('admin/hardware/message.deletefile.success')); } - $log->delete(); - return redirect()->back()->with('success', trans('admin/hardware/message.deletefile.success')); + return redirect()->back()->with('error', 'Could not find matching upload log.'); + } // Redirect to the hardware management page