From c5c831da329441c347a9b80e07693093784c52d3 Mon Sep 17 00:00:00 2001 From: Alexandre Terrasa Date: Mon, 23 May 2016 15:37:15 -0400 Subject: [PATCH] nitcorn/file_server: fix warnings on file_stat calls Signed-off-by: Alexandre Terrasa --- lib/nitcorn/file_server.nit | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/nitcorn/file_server.nit b/lib/nitcorn/file_server.nit index 0245d1f..d1a09b4 100644 --- a/lib/nitcorn/file_server.nit +++ b/lib/nitcorn/file_server.nit @@ -86,8 +86,9 @@ class FileServer # This make sure that the requested file is within the root folder. if (local_file + "/").has_prefix(root) then # Does it exists? - if local_file.file_exists then - if local_file.file_stat.is_dir then + var file_stat = local_file.file_stat + if file_stat != null then + if file_stat.is_dir then # If we target a directory without an ending `/`, # redirect to the directory ending with `/`. var uri = request.uri @@ -106,10 +107,10 @@ class FileServer end end - var is_dir = local_file.file_stat.is_dir - if show_directory_listing and is_dir then + file_stat = local_file.file_stat + if show_directory_listing and file_stat != null and file_stat.is_dir then response = answer_directory_listing(request, turi, local_file) - else if not is_dir then # It's a single file + else if file_stat != null and not file_stat.is_dir then # It's a single file response = answer_file(local_file) else response = new HttpResponse(404) else response = new HttpResponse(404) -- 1.7.9.5