Skip to content

Commit

Permalink
Merge pull request #94 from lianee/main
Browse files Browse the repository at this point in the history
Improve fileExists and directoryExists for Flysystem v3
  • Loading branch information
freekmurze authored Jul 17, 2023
2 parents 01b5302 + b860f8b commit 7668791
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/DropboxAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,25 @@ public function fileExists(string $path): bool
$location = $this->applyPathPrefix($path);

try {
$this->client->getMetadata($location);
$meta = $this->client->getMetadata($location);

return true;
return $meta['.tag'] === 'file';
} catch (BadRequest) {
return false;
}
}

public function directoryExists(string $path): bool
{
return $this->fileExists($path);
$location = $this->applyPathPrefix($path);

try {
$meta = $this->client->getMetadata($location);

return $meta['.tag'] === 'folder';
} catch (BadRequest) {
return false;
}
}

/**
Expand Down

0 comments on commit 7668791

Please sign in to comment.