update smartbucket dependency to version 4.3.0 and refactor listObjects method for improved performance
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user