Delete file from assets folder, not just the ref. (#9525)

This commit is contained in:
Tom Misilo 2021-05-05 00:18:22 -05:00 committed by GitHub
parent 57b9b571dc
commit a6bbe1fec3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -110,15 +110,15 @@ class AssetFilesController extends Controller
{ {
$asset = Asset::find($assetId); $asset = Asset::find($assetId);
$this->authorize('update', $asset); $this->authorize('update', $asset);
$rel_path = 'storage/private_uploads/assets'; $rel_path = 'private_uploads/assets';
// the asset is valid // the asset is valid
if (isset($asset->id)) { if (isset($asset->id)) {
$this->authorize('update', $asset); $this->authorize('update', $asset);
$log = Actionlog::find($fileId); $log = Actionlog::find($fileId);
if ($log) { if ($log) {
if (file_exists(base_path().'/'.$rel_path.'/'.$log->filename)) { if (Storage::exists($rel_path.'/'.$log->filename)) {
Storage::disk('public')->delete($rel_path.'/'.$log->filename); Storage::delete($rel_path.'/'.$log->filename);
} }
$log->delete(); $log->delete();
return redirect()->back()->with('success', trans('admin/hardware/message.deletefile.success')); return redirect()->back()->with('success', trans('admin/hardware/message.deletefile.success'));