MCPcopy Create free account
hub / github.com/error311/FileRise / getFolderListRemote

Method getFolderListRemote

src/FileRise/Domain/FolderModel.php:2119–2215  ·  view source on GitHub ↗
(?string $parent, ?string $username, array $perms, bool $includeCounts)

Source from the content-addressed store, hash-verified

2117 }
2118
2119 private static function getFolderListRemote(?string $parent, ?string $username, array $perms, bool $includeCounts): array
2120 {
2121 $storage = self::storage();
2122 $base = rtrim(self::uploadRoot(), "/\\");
2123
2124 $folderInfoList = [];
2125 $rootMetaFile = self::getMetadataFilePath('root');
2126 $rootFileCount = null;
2127 if ($includeCounts && file_exists($rootMetaFile)) {
2128 $rootMetadata = json_decode(file_get_contents($rootMetaFile), true);
2129 $rootFileCount = is_array($rootMetadata) ? count($rootMetadata) : 0;
2130 }
2131 $folderInfoList[] = [
2132 "folder" => "root",
2133 "fileCount" => $rootFileCount,
2134 "metadataFile" => basename($rootMetaFile)
2135 ];
2136
2137 if ($parent !== null && !$includeCounts) {
2138 $folderInfoList = self::getFolderListRemoteShallow($parent, $includeCounts);
2139 if ($username !== null) {
2140 $folderInfoList = array_values(array_filter(
2141 $folderInfoList,
2142 fn($row) => ACL::canRead($username, $perms, $row['folder'])
2143 ));
2144 }
2145 return $folderInfoList;
2146 }
2147
2148 $maxFolders = 20000;
2149 $scanned = 0;
2150 $queue = [['root', $base]];
2151
2152 $SKIP = FS::SKIP();
2153
2154 while ($queue && $scanned < $maxFolders) {
2155 [$rel, $abs] = array_shift($queue);
2156 $entries = $storage->list($abs);
2157 if (!$entries) {
2158 continue;
2159 }
2160
2161 foreach ($entries as $name) {
2162 if ($name === '.' || $name === '..') {
2163 continue;
2164 }
2165 if ($name === '' || $name[0] === '.') {
2166 continue;
2167 }
2168 if (FS::shouldIgnoreEntry($name, $rel)) {
2169 continue;
2170 }
2171 if (!FS::isSafeSegment($name)) {
2172 continue;
2173 }
2174 if (in_array(strtolower($name), $SKIP, true)) {
2175 continue;
2176 }

Callers 1

getFolderListMethod · 0.95

Calls 10

storageMethod · 0.95
uploadRootMethod · 0.95
getMetadataFilePathMethod · 0.95
canReadMethod · 0.80
SKIPMethod · 0.80
shouldIgnoreEntryMethod · 0.80
listMethod · 0.45
isSafeSegmentMethod · 0.45
statMethod · 0.45

Tested by

no test coverage detected