From cc7325074e517f2e6eccf59553d4913f77d97196 Mon Sep 17 00:00:00 2001 From: snipe Date: Mon, 6 Mar 2023 10:47:28 -0800 Subject: [PATCH] Check that the file exists before trying to stat it for filesize Signed-off-by: snipe --- app/Http/Controllers/Api/ImportController.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/Api/ImportController.php b/app/Http/Controllers/Api/ImportController.php index 2426a49bed..5874d96031 100644 --- a/app/Http/Controllers/Api/ImportController.php +++ b/app/Http/Controllers/Api/ImportController.php @@ -126,7 +126,12 @@ class ImportController extends Controller } $file_name = date('Y-m-d-his').'-'.$fixed_filename; $import->file_path = $file_name; - $import->filesize = filesize($path.'/'.$file_name); + $import->filesize = null; + + if (file_exists($path.'/'.$file_name)) { + $import->filesize = filesize($path.'/'.$file_name); + } + $import->save(); $results[] = $import; }