Fix exposing single files over webdav

This commit is contained in:
Robin Appelman 2014-05-14 23:08:45 +02:00 committed by Bjoern Schiessle
parent cf5a72c103
commit c6a83b2f17
2 changed files with 7 additions and 3 deletions

View File

@ -47,8 +47,12 @@ $server->subscribeEvent('beforeMethod', function () use ($server, $objectTree, $
$rootInfo = $view->getFileInfo(''); $rootInfo = $view->getFileInfo('');
// Create ownCloud Dir // Create ownCloud Dir
$rootDir = new OC_Connector_Sabre_Directory($view, $rootInfo); if ($rootInfo->getType() === 'dir') {
$objectTree->init($rootDir, $view); $root = new OC_Connector_Sabre_Directory($view, $rootInfo);
} else {
$root = new OC_Connector_Sabre_File($view, $rootInfo);
}
$objectTree->init($root, $view);
$server->addPlugin(new OC_Connector_Sabre_AbortedUploadDetectionPlugin($view)); $server->addPlugin(new OC_Connector_Sabre_AbortedUploadDetectionPlugin($view));
$server->addPlugin(new OC_Connector_Sabre_QuotaPlugin($view)); $server->addPlugin(new OC_Connector_Sabre_QuotaPlugin($view));

View File

@ -140,7 +140,7 @@ class OC_Connector_Sabre_File extends OC_Connector_Sabre_Node implements \Sabre\
if (\OC_Util::encryptedFiles()) { if (\OC_Util::encryptedFiles()) {
throw new \Sabre\DAV\Exception\ServiceUnavailable(); throw new \Sabre\DAV\Exception\ServiceUnavailable();
} else { } else {
return $this->fileView->fopen($this->path, 'rb'); return $this->fileView->fopen(ltrim($this->path, '/'), 'rb');
} }
} }