Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix scandir #112

Merged
merged 7 commits into from
Sep 4, 2024
Merged
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 11 additions & 13 deletions src/Storage/Device/Local.php
Original file line number Diff line number Diff line change
Expand Up @@ -364,15 +364,13 @@ public function deletePath(string $path): bool

foreach ($files as $file) {
if (is_dir($file)) {
$this->deletePath(\ltrim($file, $this->getRoot().DIRECTORY_SEPARATOR));
$this->deletePath(substr_replace($file, '', 0, strlen($this->getRoot())));
fogelito marked this conversation as resolved.
Show resolved Hide resolved
} else {
$this->delete($file, true);
}
}

\rmdir($path);

return true;
return \rmdir($path);
}

/**
Expand Down Expand Up @@ -517,18 +515,18 @@ public function getPartitionTotalSpace(): float
*/
public function getFiles(string $dir, int $max = self::MAX_PAGE_SIZE, string $continuationToken = ''): array
{
if (! (\str_ends_with($dir, DIRECTORY_SEPARATOR))) {
$dir .= DIRECTORY_SEPARATOR;
}

$dir = rtrim($dir, DIRECTORY_SEPARATOR);
$files = [];

foreach (\scandir($dir) as $file) {
if ($file === '.' || $file === '..') {
continue;
}
foreach (\glob($dir.DIRECTORY_SEPARATOR.'*') as $file) {
$files[] = $file;
}

$files[] = $dir.$file;
/**
* Hidden files
*/
foreach (\glob($dir.DIRECTORY_SEPARATOR.'.[!.]*') as $file) {
$files[] = $file;
}

return $files;
Expand Down
Loading