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); progressHandler?.reportProgress(message);
}, },
reportResult: (result) => progressHandler?.reportResult(result),
}, },
reportResult: (result) => progressHandler?.reportResult(result),
progressId, progressId,
}) })
) )

View File

@ -163,14 +163,17 @@ export namespace ExecuteWithProgress {
* _unknown_ progress if falsy. * _unknown_ progress if falsy.
*/ */
readonly progressId?: string; readonly progressId?: string;
readonly responseService: Partial< readonly responseService: Partial<ResponseService>;
ResponseService & { reportResult: (result: DownloadResult) => void } /**
>; * 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>({ export function createDataCallback<R extends ProgressResponse>({
responseService, responseService,
progressId, progressId,
reportResult,
}: ExecuteWithProgress.Options): (response: R) => void { }: ExecuteWithProgress.Options): (response: R) => void {
const uuid = v4(); const uuid = v4();
let message = ''; let message = '';
@ -252,8 +255,8 @@ export namespace ExecuteWithProgress {
}); });
} }
} else if (phase instanceof DownloadProgressEnd) { } else if (phase instanceof DownloadProgressEnd) {
if (url) { if (url && reportResult) {
responseService.reportResult?.({ reportResult({
url, url,
message: phase.getMessage(), message: phase.getMessage(),
success: phase.getSuccess(), success: phase.getSuccess(),