Skip to content

Commit

Permalink
Replace downloadObject with statObject where possible
Browse files Browse the repository at this point in the history
  • Loading branch information
Erikvv committed Dec 13, 2021
1 parent f022e00 commit 931aa50
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/StorjObjectStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public function objectExists($urn): bool
$this->logger->debug('Storj::objectExists("{urn}")', ['urn' => $urn]);

try {
$this->project->downloadObject($this->bucket, $urn);
$this->project->statObject($this->bucket, $urn);
return true;
} catch (ObjectNotFound $e) {
return false;
Expand Down
7 changes: 2 additions & 5 deletions lib/StorjStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,7 @@ public function stat($path)

if ($objectInfo === null) {
try {
$download = $this->project->downloadObject($this->bucket, $path);
$objectInfo = $download->info();
$objectInfo = $this->project->statObject($this->bucket, $path);
$this->objectInfoCache->set($path, $objectInfo);
} catch (UplinkException $e) {
$this->logger->error(
Expand Down Expand Up @@ -239,9 +238,7 @@ public function filetype($path)

if ($objectInfo === null) {
try {
$objectInfo = $this->project
->downloadObject($this->bucket, $path)
->info();
$objectInfo = $this->project->statObject($this->bucket, $path);
} catch (ObjectNotFound $e) {
// its not an object, check if it's a prefix
$objects = $this->project->listObjects($this->bucket, (new ListObjectsOptions())
Expand Down

0 comments on commit 931aa50

Please sign in to comment.