This commit is contained in:
2025-11-20 13:57:05 +00:00
parent 42974fdc0d
commit 4bb35a8947
2 changed files with 36 additions and 6 deletions

View File

@@ -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<string[]> {
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<void> => {
// 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;
}
/**

View File

@@ -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<string>();
@@ -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) {