From fcf9bf65832dc955e48284756ffa50033c1c15f1 Mon Sep 17 00:00:00 2001 From: steinm Date: Fri, 8 Feb 2013 14:56:26 +0000 Subject: [PATCH] - do not create a new version if the new file is identical to the current version --- webdav/letodms_webdav.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/webdav/letodms_webdav.php b/webdav/letodms_webdav.php index 601db0b91..c961d3c04 100644 --- a/webdav/letodms_webdav.php +++ b/webdav/letodms_webdav.php @@ -517,13 +517,22 @@ class HTTP_WebDAV_Server_LetoDMS extends HTTP_WebDAV_Server if($lastDotIndex === false) $fileType = "."; else $fileType = substr($name, $lastDotIndex); } + /* First check whether there is already a file with the same name */ if($document = $this->dms->getDocumentByName($name, $folder)) { if ($document->getAccessMode($this->user) < M_READWRITE) { unlink($tmpFile); return "403 Forbidden"; - } elseif(!$document->addContent('', $this->user, $tmpFile, $name, $fileType, $mimetype, array(), array(), 0)) { - unlink($tmpFile); - return "409 Conflict"; + } else{ + /* Check if the new version iѕ identical to the current version. + * In that case just update the modification date + */ + $lc = $document->getLatestContent(); + if($lc->getChecksum() == LetoDMS_Core_File::checksum($tmpFile)) { + $lc->setDate(); + } elseif(!$document->addContent('', $this->user, $tmpFile, $name, $fileType, $mimetype, array(), array(), 0)) { + unlink($tmpFile); + return "409 Conflict"; + } } } else {