Skip to content

Commit

Permalink
Fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
Erikvv committed Sep 30, 2021
1 parent 0903486 commit 97ea259
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 16 deletions.
2 changes: 1 addition & 1 deletion appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<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.1</version>
<version>0.0.2</version>
<licence>agpl</licence>
<author mail="[email protected]" homepage="https://github.com/erikvv">Erik van Velzen</author>
<namespace>Storj</namespace>
Expand Down
39 changes: 24 additions & 15 deletions lib/StorjStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public function deleteObject($urn): void

public function objectExists($urn): bool
{
return $this->objectExists($urn);
return $this->storjObjectStore->objectExists($urn);
}

public function copyObject($from, $to): void
Expand Down Expand Up @@ -143,7 +143,12 @@ public function opendir($path)
$path = $this->normalizePath($path);
$path = "$path/";

$listObjectOptions = new ListObjectsOptions($path, '', false, true, true);
$listObjectOptions = (new ListObjectsOptions())
->withPrefix($path)
->withCursor('')
->withSystemMetadata(true)
->withCustomMetadata(true)
->withRecursive(false);

$objectInfoIterator = $this->project->listObjects($this->bucket, $listObjectOptions);

Expand Down Expand Up @@ -171,21 +176,25 @@ public function stat($path)
];
}

try {
$download = $this->project->downloadObject($this->bucket, $path);
} catch (UplinkException $e) {
$this->logger->error(
'Storj::stat("{path}") {exception} thrown "{message}"',
[
'path' => $path,
'exception' => get_class($e),
'message' => $e->getMessage(),
]
);
return false;
$objectInfo = $this->objectInfoCache->get($path);

if ($objectInfo === null) {
try {
$download = $this->project->downloadObject($this->bucket, $path);
$objectInfo = $download->info();
} catch (UplinkException $e) {
$this->logger->error(
'Storj::stat("{path}") {exception} thrown "{message}"',
[
'path' => $path,
'exception' => get_class($e),
'message' => $e->getMessage(),
]
);
return false;
}
}

$objectInfo = $download->info();
$systemMetadata = $objectInfo->getSystemMetadata();

return [
Expand Down

0 comments on commit 97ea259

Please sign in to comment.