Skip to content

Commit 7d1975b

Browse files
committed
feat: Add recursiveFetchLogicalFiles
Fixes #4392 Signed-off-by: Gordon Smith <[email protected]>
1 parent 8ac5554 commit 7d1975b

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

packages/comms/src/ecl/logicalFile.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,10 @@ export class LogicalFile extends StateObject<FileDetailEx, FileDetailEx> impleme
176176
return this.connection.DFUFile({ Name: this.Name, Format: format });
177177
}
178178

179+
fetchAllLogicalFiles(): Promise<string[]> {
180+
return this.connection.recursiveFetchLogicalFiles([this]);
181+
}
182+
179183
fetchListHistory(): Promise<WsDfu.Origin[]> {
180184
return this.connection.ListHistory({ Name: this.Name }).then(response => {
181185
return response?.History?.Origin || [];

packages/comms/src/services/wsDFU.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,20 @@ export class DFUService extends DfuServiceBase {
1515
return this._connection.send("DFUDefFile", request, "text");
1616
}
1717

18+
async recursiveFetchLogicalFiles(superFiles: { NodeGroup: string, Name: string }[]): Promise<string[]> {
19+
const childSuperFiles: WsDfu.DFULogicalFile[] = [];
20+
const logicalFiles: string[] = [];
21+
await Promise.all(superFiles.map(superFile => {
22+
return this.DFUInfo({ Cluster: superFile.NodeGroup, Name: superFile.Name, IncludeJsonTypeInfo: false, IncludeBinTypeInfo: false, ForceIndexInfo: false })
23+
.then(response => {
24+
for (const child of response?.FileDetail?.Superfiles?.DFULogicalFile ?? []) {
25+
childSuperFiles.push(child);
26+
}
27+
for (const child of response?.FileDetail?.subfiles?.Item ?? []) {
28+
logicalFiles.push(child);
29+
}
30+
});
31+
}));
32+
return logicalFiles.concat(childSuperFiles.length ? await this.recursiveFetchLogicalFiles(childSuperFiles) : []);
33+
}
1834
}

0 commit comments

Comments
 (0)