Skip to content

Commit

Permalink
0.0.4 add error indication if FFI is disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
Erikvv committed Oct 8, 2021
1 parent 5742a14 commit 11b9b4c
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 16 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ source:
# Builds the source package for the app store, ignores php and js tests
.PHONY: appstore
appstore:
composer install --optimize-autoloader --no-dev
rm -rf $(appstore_build_directory)
mkdir -p $(appstore_build_directory)
tar cvzf $(appstore_package_name).tar.gz \
Expand Down
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
# Storj NextCloud App

**EXPERIMENTAL**
Adds external storage support for Storj Decentralized Cloud Storage.

A Storj Community contributed decentralized storage backend for Nextcloud built on Storj DCS.
Storj Community contributed.

## Prerequisites

Currently only works on x64.

The PHP installation should have the FFI extension loaded and enabled unconditionally in php.ini:

```
Expand All @@ -16,7 +18,7 @@ ffi.enable=true

## Installation

Install from the app store or place this app in the folder `apps` of the nextcloud installation
Install from the [App store](https://apps.nextcloud.com/apps/storj) or place this app in the folder `apps` of the nextcloud installation

## Configuration

Expand Down Expand Up @@ -72,7 +74,6 @@ or:

for integration tests

## Known issues and improvements
## Known issues

- Using external storage is slower than necessary because NextCloud request objects metadata separately during the same HTTP request. This can be improved by caching the results at the initial list operation.
- Under unknown circumstances a segfault seems to occur.
- Enabling Xdebug profiling or debugging will cause a segfault
43 changes: 40 additions & 3 deletions appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,46 @@
xsi:noNamespaceSchemaLocation="https://apps.nextcloud.com/schema/apps/info.xsd">
<id>storj</id>
<name>Storj</name>
<summary>Storage backend built on Storj DCS.</summary>
<description><![CDATA[A Storj Community contributed decentralized storage backend for Nextcloud built on Storj DCS.]]></description>
<version>0.0.3</version>
<summary>Decentralized storage backend</summary>
<description><![CDATA[External storage support for Storj Decentralized Cloud Storage.
Made by the Storj community.
## Prerequisites
Currently only works on x64.
The PHP installation should have the FFI extension loaded and enabled unconditionally in php.ini:
```
extension=ffi
ffi.enable=true
```
## Configuration
Storj works like any external object storage. See the documentation on docs.nextcloud.com:
* [Configuring External Storage (GUI)](https://docs.nextcloud.com/server/22/admin_manual/configuration_files/external_storage_configuration_gui.html)
* [Configuring Object Storage as Primary Storage](https://docs.nextcloud.com/server/20/admin_manual/configuration_files/primary_storage.html)
This is the configuration to set Storj as your primary storage:
```php
$CONFIG = [
'objectstore' => [
'class' => \OCA\Storj\StorjObjectStore::class,
'arguments' => [
'serialized_access' => 'myaccessgrant',
'bucket' => 'mynextcloudbucket',
]
]
];
```
]]></description>
<version>0.0.4</version>
<licence>agpl</licence>
<author mail="[email protected]" homepage="https://github.com/erikvv">Erik van Velzen</author>
<namespace>Storj</namespace>
Expand Down
28 changes: 22 additions & 6 deletions lib/StorjBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace OCA\Storj;

use ErrorException;
use Exception;
use OCA\Files_External\Lib\DefinitionParameter;
use OCA\Files_External\Lib\StorageConfig;
use OCP\Files\StorageNotAvailableException;
Expand Down Expand Up @@ -33,15 +35,29 @@ public function manipulateStorageConfig(StorageConfig &$storage, IUser $user = n
$accessGrant = $storage->getBackendOption('serialized_access');

try {
$uplink = Uplink::create();
$access = $uplink->parseAccess($accessGrant);
$project = $access->openProject();
$project->ensureBucket($bucket);
} catch (Throwable $exception) {
try {
$uplink = Uplink::create();
$access = $uplink->parseAccess($accessGrant);
$project = $access->openProject();
$project->ensureBucket($bucket);
} catch (\Error $e) {
// convert to exception or it will fail type check
throw new ErrorException(
$e->getMessage(),
$e->getCode(),
1,
$e->getFile(),
$e->getLine(),
$e
);
}
} catch (Exception $exception) {
// Will display important information for the user to fix the problemn
throw new StorageNotAvailableException(
$exception->getMessage(),
$exception->getCode(),
// code must be nonzero to display error icon
$exception->getCode() ?: 1,
$exception
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/StorjStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public function rmdir($path): bool
$this->project->deleteObject($this->bucket, $object->getKey());
$this->objectInfoCache->remove($object->getKey());
}

try {
$this->project->deleteObject($this->bucket, $path);
} catch (Throwable $e) {
Expand Down

0 comments on commit 11b9b4c

Please sign in to comment.