From 97ea25996fe700dda1ef4ec1a27074d8b652a47f Mon Sep 17 00:00:00 2001 From: Erik van Velzen Date: Thu, 30 Sep 2021 01:55:36 +0200 Subject: [PATCH] Fix bugs --- appinfo/info.xml | 2 +- lib/StorjStorage.php | 39 ++++++++++++++++++++++++--------------- 2 files changed, 25 insertions(+), 16 deletions(-) diff --git a/appinfo/info.xml b/appinfo/info.xml index 5213b1e..be37908 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -5,7 +5,7 @@ Storj Storage backend built on Storj DCS. - 0.0.1 + 0.0.2 agpl Erik van Velzen Storj diff --git a/lib/StorjStorage.php b/lib/StorjStorage.php index 63c1db4..097cae5 100644 --- a/lib/StorjStorage.php +++ b/lib/StorjStorage.php @@ -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 @@ -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); @@ -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 [