From 73d13235c4946340e9750e415472a20d6e5f5ba1 Mon Sep 17 00:00:00 2001 From: Damien <damien.burel@maarch.org> Date: Fri, 24 May 2019 11:24:03 +0200 Subject: [PATCH] FEAT #10599 TIME 0:05 Delete old document from docservers --- src/app/document/controllers/DocumentController.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/app/document/controllers/DocumentController.php b/src/app/document/controllers/DocumentController.php index 6a0c7a829b..207daf13bc 100755 --- a/src/app/document/controllers/DocumentController.php +++ b/src/app/document/controllers/DocumentController.php @@ -304,8 +304,8 @@ class DocumentController } $pathToDocument = $docserver['path'] . $adr[0]['path'] . $adr[0]['filename']; - if (!file_exists($pathToDocument)) { - return $response->withStatus(404)->withJson(['errors' => 'Document not found on docserver']); + if (!is_file($pathToDocument) || !is_readable($pathToDocument)) { + return $response->withStatus(404)->withJson(['errors' => 'Document not found on docserver or not readable']); } $tmpPath = CoreConfigModel::getTmpPath(); @@ -391,6 +391,7 @@ class DocumentController return $response->withStatus(500)->withJson(['errors' => $storeInfos['errors']]); } + unlink($pathToDocument); AdrModel::deleteDocumentAdr([ 'where' => ['main_document_id = ?', 'type = ?'], 'data' => [$args['id'], 'DOC'] -- GitLab