Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 20 additions & 46 deletions lib/Sabre/WebDavPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

namespace OCA\Files_External_Ethswarm\Sabre;

use Exception;
use OCA\DAV\Connector\Sabre\Directory;
use OCA\DAV\Connector\Sabre\File;
use OCA\Files_External_Ethswarm\Service\EthswarmService;
Expand Down Expand Up @@ -101,61 +102,35 @@ public function httpPost(RequestInterface $request, ResponseInterface $response)
}

try {
switch ($action) {
case 'hide':
$path = $request->getPath();
$node = $this->server->tree->getNodeForPath($path);
if ($node instanceof File) {
$storageid = $node->getFileInfo()->getStorage()->getCache()->getNumericStorageId();
$filename = $node->getFileInfo()->getinternalPath();
}
if ($node instanceof Directory) {
$storageid = $node->getFileInfo()->getStorage()->getCache()->getNumericStorageId();
$filename = $node->getFileInfo()->getinternalPath();
}

$this->EthswarmService->setVisibility($filename, $storageid, 0);
$path = $request->getPath();
$node = $this->server->tree->getNodeForPath($path);

break;
if (!$node instanceof File && !$node instanceof Directory) {
return true;
}

$fileInfo = $node->getFileInfo();
$filename = $fileInfo->getinternalPath();
$storage = $fileInfo->getMountPoint()->getStorage();
$storageid = $fileInfo->getStorage()->getCache()->getNumericStorageId();

switch ($action) {
case 'hide':
case 'unhide':
$path = $request->getPath();
$node = $this->server->tree->getNodeForPath($path);
if ($node instanceof File) {
$storageid = $node->getFileInfo()->getStorage()->getCache()->getNumericStorageId();
$filename = $node->getFileInfo()->getinternalPath();
}
if ($node instanceof Directory) {
$storageid = $node->getFileInfo()->getStorage()->getCache()->getNumericStorageId();
$filename = $node->getFileInfo()->getinternalPath();
}

$this->EthswarmService->setVisibility($filename, $storageid, 1);
$hide = 'hide' === $action ? 0 : 1;
$this->EthswarmService->setVisibility($filename, $storageid, $hide);

break;

case 'archive':
$path = $request->getPath();
$node = $this->server->tree->getNodeForPath($path);
if ($node instanceof File || $node instanceof Directory) {
$fileInfo = $node->getFileInfo();
$filename = $fileInfo->getInternalPath();
$storage = $fileInfo->getMountPoint()->getStorage();
$this->EthswarmService->archiveNode($filename, $storage);
}
$this->EthswarmService->archiveNode($filename, $storage);

break;

case 'unarchive' || 'move':
$path = $request->getPath();
case 'unarchive':
case 'move':
$destination = $request->getHeader('Destination');
$node = $this->server->tree->getNodeForPath($path);
if ($node instanceof File || $node instanceof Directory) {
$fileInfo = $node->getFileInfo();
$filename = $fileInfo->getInternalPath();
$storage = $fileInfo->getMountPoint()->getStorage();
$this->EthswarmService->moveNode($filename, $storage, $destination);
}
$this->EthswarmService->moveNode($filename, $storage, $destination);

break;

Expand All @@ -167,7 +142,7 @@ public function httpPost(RequestInterface $request, ResponseInterface $response)
'status' => true,
'message' => 'success',
]));
} catch (\Exception $ex) {
} catch (Exception $ex) {
$response->setBody(json_encode([
'status' => false,
'message' => $ex->getMessage(),
Expand Down Expand Up @@ -203,7 +178,6 @@ public function httpMove(RequestInterface $request, ResponseInterface $response)
} catch (Exception $ex) {
$response->setStatus(500);
}
$response->setHeader('Content-Length', '0');

return false;
}
Expand Down