Return 404 if download file isn’t found

Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
snipe 2024-02-19 13:05:44 +00:00
parent cae2de4fc9
commit c76fbe4edb

View file

@ -267,12 +267,13 @@ class SettingsController extends Controller
public function downloadBackup($file) {
$path = 'app/backups';
if (Storage::exists($path.'/'.$file)) {
$path = storage_path('app/backups');
if (Storage::exists('app/backups/'.$file)) {
$headers = ['ContentType' => 'application/zip'];
return response()->download($path.'/'.$file, $file, $headers);
} else {
return response()->json(Helper::formatStandardApiResponse('error', null, trans('general.file_not_found')));
return response()->json(Helper::formatStandardApiResponse('error', null, trans('general.file_not_found')), 404);
}
}