Skip to content

Commit

Permalink
fix: iterator for local filesystems
Browse files Browse the repository at this point in the history
  • Loading branch information
augustas committed Oct 15, 2024
1 parent ada7d99 commit 810ab96
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 409 deletions.
11 changes: 8 additions & 3 deletions common/oatbox/filesystem/Directory.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,13 @@ public function getFlyIterator($flags = null)
$contents = $this->getFileSystem()->listContents($this->getPrefix(), $recursive);

if (!empty($contents)) {
$dirPath = $this->getPrefix();
foreach ($contents as $content) {
if ($withDirectories && $content['type'] == 'dir') {
$iterator[] = $this->getDirectory(str_replace($dirPath, '', $content['path']));
$iterator[] = $this->getDirectory($this->stripDirectoryPath($content['path']));
}

if ($withFiles && $content['type'] == 'file') {
$iterator[] = $this->getFile(str_replace($dirPath, '', $content['path']));
$iterator[] = $this->getFile($this->stripDirectoryPath($content['path']));
}
}
}
Expand Down Expand Up @@ -207,4 +206,10 @@ public function rename($path)

return true;
}

private function stripDirectoryPath(string $path): string
{
$strippedPath = str_replace($this->getPrefix(), '', $path);
return str_replace($this->getFileSystemId(), '', $strippedPath);
}
}
2 changes: 1 addition & 1 deletion common/oatbox/filesystem/FileSystemService.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ public function registerLocalFileSystem($id, $path)
$adapters = $this->hasOption(self::OPTION_ADAPTERS) ? $this->getOption(self::OPTION_ADAPTERS) : [];
$adapters[$id] = [
'class' => LocalFilesystemAdapter::class,
'options' => ['root' => $path]
'options' => ['location' => $path]
];
$this->setOption(self::OPTION_ADAPTERS, $adapters);
return true;
Expand Down
211 changes: 0 additions & 211 deletions common/oatbox/filesystem/utils/FlyWrapperTrait.php

This file was deleted.

Loading

0 comments on commit 810ab96

Please sign in to comment.