[bugfix] fix download success notification when canceling oculus download

This commit is contained in:
MathieuG-P
2023-11-12 13:35:34 +01:00
parent 6f46b943c9
commit ce0e7ae19e
3 changed files with 14 additions and 4 deletions
+2 -1
View File
@@ -6,6 +6,7 @@ import path from "path";
import { inflate } from "pako"
import { EMPTY, Observable, ReplaySubject, Subscriber, catchError, filter, from, lastValueFrom, mergeMap, scan, share, tap } from "rxjs";
import { Progression, hashFile } from "../helpers/fs.helpers";
import { OculusDownloaderErrorCodes } from "../../shared/models/bs-version-download/oculus-download.model";
export class OculusDownloader {
@@ -196,7 +197,7 @@ export class OculusDownloader {
public stopDownload(){
this.isDownloading = false;
this.downloadSubscriber?.complete();
this.downloadSubscriber?.error(CustomError.fromError(new Error("Download canceled"), OculusDownloaderErrorCodes.DOWNLOAD_CANCELLED));
}
}
@@ -70,7 +70,7 @@ export class OculusDownloaderService extends AbstractBsDownloaderService impleme
}
private tryAutoDownload(downloadInfo: DownloadInfo): Observable<Progression<BSVersion>>{
const ignoreCode = [MetaAuthErrorCodes.NO_META_AUTH_TOKEN];
const ignoreCode = [MetaAuthErrorCodes.NO_META_AUTH_TOKEN, OculusDownloaderErrorCodes.DOWNLOAD_CANCELLED];
return this.handleDownload(
this.ipc.sendV2<Progression<BSVersion>>("bs-oculus-auto-download", { args: downloadInfo }),
ignoreCode
@@ -78,7 +78,7 @@ export class OculusDownloaderService extends AbstractBsDownloaderService impleme
}
private startDownloadBsVersion(downloadInfo: DownloadInfo): Observable<Progression<BSVersion>>{
const ignoreCode = [MetaAuthErrorCodes.META_LOGIN_WINDOW_CLOSED_BY_USER];
const ignoreCode = [MetaAuthErrorCodes.META_LOGIN_WINDOW_CLOSED_BY_USER, OculusDownloaderErrorCodes.DOWNLOAD_CANCELLED];
return this.handleDownload(
this.ipc.sendV2<Progression<BSVersion>>("bs-oculus-download", { args: downloadInfo }),
ignoreCode
@@ -92,7 +92,12 @@ export class OculusDownloaderService extends AbstractBsDownloaderService impleme
return (async () => {
const autoDownload = await lastValueFrom(this.tryAutoDownload({ bsVersion, isVerification })).then(() => true).catch((err: CustomError) => {
const doNotRestartCodes: string[] = [OculusDownloaderErrorCodes.ALREADY_DOWNLOADING, OculusDownloaderErrorCodes.SOME_FILES_FAILED_TO_DOWNLOAD, OculusDownloaderErrorCodes.VERIFY_INTEGRITY_FAILED];
const doNotRestartCodes: string[] = [
OculusDownloaderErrorCodes.ALREADY_DOWNLOADING,
OculusDownloaderErrorCodes.SOME_FILES_FAILED_TO_DOWNLOAD,
OculusDownloaderErrorCodes.VERIFY_INTEGRITY_FAILED,
OculusDownloaderErrorCodes.DOWNLOAD_CANCELLED
];
autoDownloadFailed = true;
if(doNotRestartCodes.includes(err?.code)){
@@ -123,6 +128,9 @@ export class OculusDownloaderService extends AbstractBsDownloaderService impleme
return lastValueFrom(this.startDownloadBsVersion({ bsVersion, isVerification, token: tokenRes.data })).then(() => true);
})().then(res => {
console.log("aaa", res);
if(autoDownloadFailed || !res){
return bsVersion;
}
@@ -7,6 +7,7 @@ export enum OculusDownloaderErrorCodes {
UNABLE_TO_GET_MANIFEST = "UNABLE_TO_GET_MANIFEST",
VERIFY_INTEGRITY_FAILED = "VERIFY_INTEGRITY_FAILED",
SOME_FILES_FAILED_TO_DOWNLOAD = "SOME_FILES_FAILED_TO_DOWNLOAD",
DOWNLOAD_CANCELLED = "DOWNLOAD_CANCELLED",
}
export enum MetaAuthErrorCodes {