Avoid using reportResult if installing lib/core

Closes #1529

Signed-off-by: Akos Kitta <a.kitta@arduino.cc>
This commit is contained in:
Akos Kitta 2022-10-05 15:27:29 +02:00 committed by Akos Kitta
parent aa0807ca3f
commit 019b2d5588
2 changed files with 9 additions and 6 deletions

View File

@ -370,8 +370,8 @@ export class CoreClientProvider {
);
progressHandler?.reportProgress(message);
},
reportResult: (result) => progressHandler?.reportResult(result),
},
reportResult: (result) => progressHandler?.reportResult(result),
progressId,
})
)

View File

@ -163,14 +163,17 @@ export namespace ExecuteWithProgress {
* _unknown_ progress if falsy.
*/
readonly progressId?: string;
readonly responseService: Partial<
ResponseService & { reportResult: (result: DownloadResult) => void }
>;
readonly responseService: Partial<ResponseService>;
/**
* It's only relevant for index updates to build a summary of possible client (4xx) and server (5xx) errors when downloading the files during the index update. It's missing for lib/platform installations.
*/
readonly reportResult?: (result: DownloadResult) => void;
}
export function createDataCallback<R extends ProgressResponse>({
responseService,
progressId,
reportResult,
}: ExecuteWithProgress.Options): (response: R) => void {
const uuid = v4();
let message = '';
@ -252,8 +255,8 @@ export namespace ExecuteWithProgress {
});
}
} else if (phase instanceof DownloadProgressEnd) {
if (url) {
responseService.reportResult?.({
if (url && reportResult) {
reportResult({
url,
message: phase.getMessage(),
success: phase.getSuccess(),