Merge pull request #12623 from snipe/bug/sc-20254/errorexception-filesize-stat-failed-for-snipe

Check that the file exists before trying to stat it for filesize
This commit is contained in:
snipe 2023-03-06 15:43:17 -08:00 committed by GitHub
commit 0d3388b3ae
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 2 deletions

View file

@ -126,7 +126,14 @@ class ImportController extends Controller
}
$file_name = date('Y-m-d-his').'-'.$fixed_filename;
$import->file_path = $file_name;
$import->filesize = null;
if (!file_exists($path.'/'.$file_name)) {
return response()->json(Helper::formatStandardApiResponse('error', null, trans('general.file_not_found')), 500);
}
$import->filesize = filesize($path.'/'.$file_name);
$import->save();
$results[] = $import;
}

View file

@ -271,7 +271,7 @@ class SettingsController extends Controller
$headers = ['ContentType' => 'application/zip'];
return Storage::download($path.'/'.$file, $file, $headers);
} else {
return response()->json(Helper::formatStandardApiResponse('error', null, 'File not found'));
return response()->json(Helper::formatStandardApiResponse('error', null, trans('general.file_not_found')));
}
}

View file

@ -395,7 +395,7 @@ return [
'end_date' => 'Enddatum',
'alt_uploaded_image_thumbnail' => 'Hochgeladene Miniaturansicht',
'placeholder_kit' => 'Kit auswählen',
'file_not_found' => 'File not found',
'file_not_found' => 'File not found on server',
'preview_not_available' => '(no preview)',
'setup' => 'Setup',
'pre_flight' => 'Pre-Flight',