Skip to content

Commit 8b8e157

Browse files
committed
fix: #35 several broken prefix paths
1 parent ed8d596 commit 8b8e157

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

src/BunnyCDNAdapter.php

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,8 @@ public function listContents(string $path = '', bool $deep = false): iterable
147147
*/
148148
protected function normalizeObject(array $bunny_file_array): StorageAttributes
149149
{
150+
$bunny_file_array['Path'] = str_replace($this->prefixPath, '', $bunny_file_array['Path']);
151+
150152
return match ($bunny_file_array['IsDirectory']) {
151153
true => new DirectoryAttributes(
152154
Util::normalizePath(
@@ -241,6 +243,8 @@ public function writeStream($path, $contents, Config $config): void
241243
*/
242244
public function readStream($path)
243245
{
246+
$this->prependPrefix($path);
247+
244248
try {
245249
return $this->client->stream($path);
246250
// @codeCoverageIgnoreStart
@@ -306,8 +310,6 @@ public function setVisibility(string $path, string $visibility): void
306310
*/
307311
public function visibility(string $path): FileAttributes
308312
{
309-
$this->prependPrefix($path);
310-
311313
try {
312314
return new FileAttributes($this->getObject($path)->path(), null, $this->pullzone_url ? 'public' : 'private');
313315
} catch (UnableToReadFile|TypeError $e) {
@@ -323,8 +325,6 @@ public function visibility(string $path): FileAttributes
323325
*/
324326
public function mimeType(string $path): FileAttributes
325327
{
326-
$this->prependPrefix($path);
327-
328328
try {
329329
$object = $this->getObject($path);
330330

@@ -363,8 +363,6 @@ public function mimeType(string $path): FileAttributes
363363
*/
364364
protected function getObject(string $path = ''): StorageAttributes
365365
{
366-
$this->prependPrefix($path);
367-
368366
$directory = pathinfo($path, PATHINFO_DIRNAME);
369367
$list = (new DirectoryListing($this->listContents($directory)))
370368
->filter(function (StorageAttributes $item) use ($path) {
@@ -390,8 +388,6 @@ protected function getObject(string $path = ''): StorageAttributes
390388
*/
391389
public function lastModified(string $path): FileAttributes
392390
{
393-
$this->prependPrefix($path);
394-
395391
try {
396392
return $this->getObject($path);
397393
} catch (UnableToReadFile $e) {
@@ -407,8 +403,6 @@ public function lastModified(string $path): FileAttributes
407403
*/
408404
public function fileSize(string $path): FileAttributes
409405
{
410-
$this->prependPrefix($path);
411-
412406
try {
413407
return $this->getObject($path);
414408
} catch (UnableToReadFile $e) {
@@ -468,8 +462,6 @@ public function directoryExists(string $path): bool
468462
*/
469463
public function fileExists(string $path): bool
470464
{
471-
$this->prependPrefix($path);
472-
473465
$list = new DirectoryListing($this->listContents(
474466
Util::splitPathIntoDirectoryAndFile($path)['dir']
475467
));

0 commit comments

Comments
 (0)