Skip to content

Commit

Permalink
Only enable files_drop plugin when we actuall do files_drop
Browse files Browse the repository at this point in the history
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
  • Loading branch information
rullzer committed Oct 24, 2016
1 parent 0abcc63 commit c8a13f6
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
5 changes: 5 additions & 0 deletions apps/dav/appinfo/v1/publicwebdav.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@
$fileInfo = $ownerView->getFileInfo($path);
$linkCheckPlugin->setFileInfo($fileInfo);

// If not readble (files_drop) enable the filesdrop plugin
if (!$isReadable) {
$filesDropPlugin->enable();
}

$view = new \OC\Files\View($ownerView->getAbsolutePath($path));
$filesDropPlugin->setView($view);

Expand Down
20 changes: 16 additions & 4 deletions apps/dav/lib/Files/Sharing/FilesDropPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,24 @@
*/
class FilesDropPlugin extends ServerPlugin {

/**
* @var View
*/
/** @var View */
private $view;

/** @var bool */
private $enabled = false;

/**
* @param View $view
*/
public function setView($view) {
$this->view = $view;
}

public function enable() {
$this->enabled = true;
}


/**
* This initializes the plugin.
*
Expand All @@ -52,10 +58,16 @@ public function setView($view) {
* @return void
*/
public function initialize(\Sabre\DAV\Server $server) {
$server->on('beforeMethod', [$this, 'beforeMethod']);
$server->on('beforeMethod:PUT', [$this, 'beforeMethod']);
$this->enabled = false;
}

public function beforeMethod(RequestInterface $request, ResponseInterface $response){

if (!$this->enabled) {
return;
}

$path = $request->getPath();

if ($this->view->file_exists($path)) {
Expand Down

0 comments on commit c8a13f6

Please sign in to comment.