- do not create a new version if the new file is identical to the

current version
This commit is contained in:
steinm 2013-02-08 14:56:26 +00:00
parent 8c0f37c7f6
commit fcf9bf6583

View File

@ -517,13 +517,22 @@ class HTTP_WebDAV_Server_LetoDMS extends HTTP_WebDAV_Server
if($lastDotIndex === false) $fileType = "."; if($lastDotIndex === false) $fileType = ".";
else $fileType = substr($name, $lastDotIndex); 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 = $this->dms->getDocumentByName($name, $folder)) {
if ($document->getAccessMode($this->user) < M_READWRITE) { if ($document->getAccessMode($this->user) < M_READWRITE) {
unlink($tmpFile); unlink($tmpFile);
return "403 Forbidden"; return "403 Forbidden";
} elseif(!$document->addContent('', $this->user, $tmpFile, $name, $fileType, $mimetype, array(), array(), 0)) { } else{
unlink($tmpFile); /* Check if the new version iѕ identical to the current version.
return "409 Conflict"; * 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 { } else {