From b02cda62273c6d57f3a48e3c5b2a07b9270bd2b8 Mon Sep 17 00:00:00 2001 From: Armand Bahi <armand.bahi@veremes.com> Date: Wed, 23 Jan 2019 16:07:19 +0100 Subject: [PATCH] Retour 404 si le fichier n'existe pas --- src/vitis/vas/rest/ws/vitis/FileDownloader.class.inc | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/vitis/vas/rest/ws/vitis/FileDownloader.class.inc b/src/vitis/vas/rest/ws/vitis/FileDownloader.class.inc index 42420a50..3e7fc84f 100755 --- a/src/vitis/vas/rest/ws/vitis/FileDownloader.class.inc +++ b/src/vitis/vas/rest/ws/vitis/FileDownloader.class.inc @@ -143,11 +143,17 @@ class FileDownloader extends Vitis { $sMessage = array("status" => 0, "sMessage" => "This directory can't be replaced by our replacer"); } // check eTag - $sEtag = sha1(file_get_contents($sPath), false); - - if ($sEtag != $this->aValues['eTag']){ + if (file_exists($sPath)) { + $sEtag = sha1(file_get_contents($sPath), false); + if ($sEtag != $this->aValues['eTag']){ + $bReturnFile = false; + $sMessage = array("status" => 0, "sMessage" => "This file doesn't exist or the Etag doesn't match"); + http_response_code(404); + } + } else { $bReturnFile = false; $sMessage = array("status" => 0, "sMessage" => "This file doesn't exist or the Etag doesn't match"); + http_response_code(404); } } -- GitLab