Remove checksum on upload of non checksumed file

When we overwrite a checksumed file with a file without a checksum we
should remove the checksum from the server.

This is done by setting the column to empty.
This commit is contained in:
Roeland Jago Douma 2016-02-28 19:41:46 +01:00 committed by Vincent Petry
parent 03d0fa012f
commit 3e88a5067f
2 changed files with 8 additions and 1 deletions

View File

@ -218,6 +218,8 @@ class File extends Node implements IFile {
if (isset($request->server['HTTP_OC_CHECKSUM'])) { if (isset($request->server['HTTP_OC_CHECKSUM'])) {
$checksum = trim($request->server['HTTP_OC_CHECKSUM']); $checksum = trim($request->server['HTTP_OC_CHECKSUM']);
$this->fileView->putFileInfo($this->path, ['checksum' => $checksum]); $this->fileView->putFileInfo($this->path, ['checksum' => $checksum]);
} else if ($this->getChecksum() !== NULL && $this->getChecksum() !== '') {
$this->fileView->putFileInfo($this->path, ['checksum' => '']);
} }
$this->refreshInfo(); $this->refreshInfo();

View File

@ -27,6 +27,7 @@
namespace OCA\DAV\Connector\Sabre; namespace OCA\DAV\Connector\Sabre;
use Sabre\DAV\Exception\NotFound;
use Sabre\DAV\IFile; use Sabre\DAV\IFile;
use \Sabre\DAV\PropFind; use \Sabre\DAV\PropFind;
use \Sabre\DAV\PropPatch; use \Sabre\DAV\PropPatch;
@ -197,7 +198,7 @@ class FilesPlugin extends \Sabre\DAV\ServerPlugin {
//Add OC-Checksum header //Add OC-Checksum header
/** @var $node File */ /** @var $node File */
$checksum = $node->getChecksum(); $checksum = $node->getChecksum();
if ($checksum !== null) { if ($checksum !== null && $checksum !== '') {
$response->addHeader('OC-Checksum', $checksum); $response->addHeader('OC-Checksum', $checksum);
} }
} }
@ -252,6 +253,10 @@ class FilesPlugin extends \Sabre\DAV\ServerPlugin {
$propFind->handle(self::CHECKSUMS_PROPERTYNAME, function() use ($node) { $propFind->handle(self::CHECKSUMS_PROPERTYNAME, function() use ($node) {
$checksum = $node->getChecksum(); $checksum = $node->getChecksum();
if ($checksum === NULL || $checksum === '') {
return null;
}
return new ChecksumList($checksum); return new ChecksumList($checksum);
}); });