Skip to content

Commit

Permalink
ocs delete externalfolder
Browse files Browse the repository at this point in the history
  • Loading branch information
ArtificialOwl committed Oct 18, 2021
1 parent 396beb6 commit e380e0e
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
1 change: 1 addition & 0 deletions appinfo/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
['name' => 'Local#getRestoringPoints', 'url' => '/rp', 'verb' => 'GET'],
['name' => 'Local#getExternalFolder', 'url' => '/external', 'verb' => 'GET'],
['name' => 'Local#setExternalFolder', 'url' => '/external', 'verb' => 'POST'],
['name' => 'Local#unsetExternalFolder', 'url' => '/external/{storageId}', 'verb' => 'DELETE'],
['name' => 'Local#initAction', 'url' => '/action/{type}/{param}', 'verb' => 'POST']
],

Expand Down
22 changes: 20 additions & 2 deletions lib/Controller/LocalController.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,8 @@ public function initAction(string $type, string $param = ''): DataResponse {
* @return DataResponse
*/
public function getRestoringPoints(): DataResponse {
$points =$this->cronService->getRPFromInstances();
$points = $this->cronService->getRPFromInstances();

return new DataResponse($points);
}

Expand Down Expand Up @@ -213,7 +214,7 @@ public function setExternalFolder(int $storageId, string $root): DataResponse {
if ($root === '') {
throw new OcsException('empty root');
}

$storages = $this->externalFolderService->getStorages();
foreach ($storages as $storage) {
if ($storage->getStorageId() === $storageId) {
Expand All @@ -234,6 +235,23 @@ public function setExternalFolder(int $storageId, string $root): DataResponse {
}


/**
* @param int $storageId
*
* @return DataResponse
* @throws OCSException
*/
public function unsetExternalFolder(int $storageId): DataResponse {
try {
$this->externalFolderService->remove($storageId);

return new DataResponse();
} catch (Exception $e) {
throw new OcsException($e->getMessage(), Http::STATUS_BAD_REQUEST);
}
}


/**
* @param int $fileId
*
Expand Down
8 changes: 8 additions & 0 deletions lib/Service/ExternalFolderService.php
Original file line number Diff line number Diff line change
Expand Up @@ -876,4 +876,12 @@ public function save(ExternalFolder $storage) {
$this->externalFolderRequest->save($storage);
}


/**
* @param int $storageId
*/
public function remove(int $storageId) {
$this->externalFolderRequest->remove($storageId);
}

}

0 comments on commit e380e0e

Please sign in to comment.