diff --git a/ts/core/classes.registrystorage.ts b/ts/core/classes.registrystorage.ts index 3494021..4f41a3e 100644 --- a/ts/core/classes.registrystorage.ts +++ b/ts/core/classes.registrystorage.ts @@ -70,15 +70,43 @@ export class RegistryStorage implements IStorageBackend { } /** - * List objects with a prefix + * List objects with a prefix (recursively) */ public async listObjects(prefix: string): Promise { - const baseDir = await this.bucket.getBaseDirectory(); - const dir = prefix ? await baseDir.getSubDirectoryByName(prefix) : baseDir; - if (!dir) return []; + const paths: string[] = []; - const files = await dir.listFiles(); - return files.map(f => f.getBasePath()); + const collectFiles = async (dir: plugins.smartbucket.Directory): Promise => { + // List all files in current directory + const files = await dir.listFiles(); + for (const file of files) { + paths.push(file.getBasePath()); + } + + // Recursively process subdirectories + const subdirs = await dir.listDirectories(); + for (const subdir of subdirs) { + await collectFiles(subdir); + } + }; + + try { + const baseDir = await this.bucket.getBaseDirectory(); + if (prefix) { + const targetDir = await baseDir.getSubDirectoryByName(prefix, { + getEmptyDirectory: true, + }); + if (targetDir) { + await collectFiles(targetDir); + } + } else { + await collectFiles(baseDir); + } + } catch (error) { + // Directory not found or other error - return empty array + return []; + } + + return paths; } /** diff --git a/ts/npm/classes.npmregistry.ts b/ts/npm/classes.npmregistry.ts index 2a358d0..6331aeb 100644 --- a/ts/npm/classes.npmregistry.ts +++ b/ts/npm/classes.npmregistry.ts @@ -537,6 +537,7 @@ export class NpmRegistry extends BaseRegistry { try { // List all package paths const packagePaths = await this.storage.listObjects('npm/packages/'); + console.log(`[handleSearch] packagePaths (${packagePaths.length}):`, packagePaths.slice(0, 10)); // Extract unique package names from paths (format: npm/packages/{packageName}/...) const packageNames = new Set(); @@ -546,6 +547,7 @@ export class NpmRegistry extends BaseRegistry { packageNames.add(match[1]); } } + console.log(`[handleSearch] Found ${packageNames.size} packages:`, Array.from(packageNames)); // Load packuments and filter by search text for (const packageName of packageNames) {