From b2f855bec0fe98d3434b265c21116883a8b72ed3 Mon Sep 17 00:00:00 2001 From: MathieuG-P <40181755+Zagrios@users.noreply.github.com> Date: Sat, 12 Apr 2025 09:57:41 +0200 Subject: [PATCH] [chore] add logs in oculus downloader (#851) --- src/main/models/oculus-downloader.class.ts | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/main/models/oculus-downloader.class.ts b/src/main/models/oculus-downloader.class.ts index b9592ea3..a9e930c0 100644 --- a/src/main/models/oculus-downloader.class.ts +++ b/src/main/models/oculus-downloader.class.ts @@ -88,7 +88,10 @@ export class OculusDownloader { sub.next(progress); } - })().catch(err => sub.error(err)).finally(() => { + })() + .then(() => { + log.info("Downloaded file to", `"${destination}"`); + }).catch(err => sub.error(err)).finally(() => { sub.complete(); writeStream?.end(); }); @@ -101,6 +104,7 @@ export class OculusDownloader { } private async isFileIntegrityValid(file: OculusFileWithName, folder: string): Promise { + const [filename, fileData] = file; const destination = path.join( folder, @@ -110,8 +114,15 @@ export class OculusDownloader { ); return pathExists(destination).then(exists => { - if(!exists){ return false; } - return hashFile(destination, "sha256").then(hash => hash === fileData.sha256); + if(!exists){ + log.info("File not found", `"${destination}"`); + return false; + } + return hashFile(destination, "sha256").then(hash => { + const isValid = hash === fileData.sha256; + log.info("File integrity", isValid ? "VALID" : "INVALID", `"${destination}"`); + return isValid; + }); }); } @@ -130,6 +141,7 @@ export class OculusDownloader { if(canceled){ return; } if(!(await this.isFileIntegrityValid(oculusFile, folder))){ + log.info("File integrity invalid", `"${oculusFile[0]}"`); wrongFiles.push(oculusFile); } @@ -188,7 +200,6 @@ export class OculusDownloader { ? filename : filename.replaceAll("\\", "/") ); - log.info("Downloaded file", `"${filename}"`, "to", `"${target}"`); return this.downloadManifestFile(file, target).pipe( catchError(err => {