update smartbucket dependency to version 4.3.0 and refactor listObjects method for improved performance

This commit is contained in:
2025-11-20 15:22:43 +00:00
parent 4bb35a8947
commit 057383fb7c
3 changed files with 33 additions and 148 deletions

View File

@@ -74,38 +74,9 @@ export class RegistryStorage implements IStorageBackend {
*/
public async listObjects(prefix: string): Promise<string[]> {
const paths: string[] = [];
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 [];
for await (const path of this.bucket.listAllObjects(prefix)) {
paths.push(path);
}
return paths;
}