Skip to content

Commit

Permalink
Return 404 if download file isn’t found
Browse files Browse the repository at this point in the history
Signed-off-by: snipe <[email protected]>
  • Loading branch information
snipe committed Feb 19, 2024
1 parent cae2de4 commit c76fbe4
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions app/Http/Controllers/Api/SettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -267,12 +267,13 @@ public function listBackups() {

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);
}

}
Expand Down

0 comments on commit c76fbe4

Please sign in to comment.