update
This commit is contained in:
@@ -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[]> {
|
public async listObjects(prefix: string): Promise<string[]> {
|
||||||
const baseDir = await this.bucket.getBaseDirectory();
|
const paths: string[] = [];
|
||||||
const dir = prefix ? await baseDir.getSubDirectoryByName(prefix) : baseDir;
|
|
||||||
if (!dir) return [];
|
|
||||||
|
|
||||||
|
const collectFiles = async (dir: plugins.smartbucket.Directory): Promise<void> => {
|
||||||
|
// List all files in current directory
|
||||||
const files = await dir.listFiles();
|
const files = await dir.listFiles();
|
||||||
return files.map(f => f.getBasePath());
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -537,6 +537,7 @@ export class NpmRegistry extends BaseRegistry {
|
|||||||
try {
|
try {
|
||||||
// List all package paths
|
// List all package paths
|
||||||
const packagePaths = await this.storage.listObjects('npm/packages/');
|
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}/...)
|
// Extract unique package names from paths (format: npm/packages/{packageName}/...)
|
||||||
const packageNames = new Set<string>();
|
const packageNames = new Set<string>();
|
||||||
@@ -546,6 +547,7 @@ export class NpmRegistry extends BaseRegistry {
|
|||||||
packageNames.add(match[1]);
|
packageNames.add(match[1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
console.log(`[handleSearch] Found ${packageNames.size} packages:`, Array.from(packageNames));
|
||||||
|
|
||||||
// Load packuments and filter by search text
|
// Load packuments and filter by search text
|
||||||
for (const packageName of packageNames) {
|
for (const packageName of packageNames) {
|
||||||
|
|||||||
Reference in New Issue
Block a user