Fixes #6514 -- Hide all dot-prefixed files, not just our protected directories.

This commit is contained in:
Buster Neece 2023-08-20 03:01:50 -05:00
parent bbd92f60ac
commit 1dc0cc32fd
No known key found for this signature in database
5 changed files with 8 additions and 7 deletions

View File

@ -205,7 +205,7 @@ final class ListAction implements SingleActionInterface
$files = $fs->listContents($currentDir, false)->filter(
fn(StorageAttributes $attributes) => !(
$currentDir === ''
&& StationFilesystems::isProtectedDir($attributes->path())
&& StationFilesystems::isDotFile($attributes->path())
)
);
}

View File

@ -31,7 +31,7 @@ final class ListDirectoriesAction implements SingleActionInterface
$directoriesRaw = $fsMedia->listContents($currentDir, false)->filter(
fn(StorageAttributes $attrs) => $attrs->isDir()
&& !StationFilesystems::isProtectedDir($attrs->path())
&& !StationFilesystems::isDotFile($attrs->path())
)->sortByPath();
$directories = [];

View File

@ -35,7 +35,7 @@ final class GetApplyToAction implements SingleActionInterface
// Iterate all directories to show them as selectable.
$fsIterator = $fsMedia->listContents('/', true)->filter(
fn(StorageAttributes $attrs) => $attrs->isDir() && !StationFilesystems::isProtectedDir($attrs->path())
fn(StorageAttributes $attrs) => $attrs->isDir() && !StationFilesystems::isDotFile($attrs->path())
)->sortByPath();
$directories = [

View File

@ -98,10 +98,11 @@ final class StationFilesystems
return new LocalFilesystem(new LocalFilesystemAdapter($path));
}
public static function isProtectedDir(string $path): bool
public static function isDotFile(string $path): bool
{
foreach (self::PROTECTED_DIRS as $protectedDir) {
if (str_starts_with($path, $protectedDir)) {
$pathParts = explode('/', $path);
foreach ($pathParts as $part) {
if (str_starts_with($part, '.')) {
return true;
}
}

View File

@ -92,7 +92,7 @@ final class CheckMediaTask extends AbstractTask
try {
$fsIterator = $fs->listContents('/', true)->filter(
fn(StorageAttributes $attrs) => $attrs->isFile() && !StationFilesystems::isProtectedDir($attrs->path())
fn(StorageAttributes $attrs) => $attrs->isFile() && !StationFilesystems::isDotFile($attrs->path())
);
} catch (FilesystemException $e) {
$this->logger->error(