From 00a940190f97c64e7c7b1fca4c4c2e1fac65061e Mon Sep 17 00:00:00 2001 From: Alper Alkan Date: Fri, 21 Jun 2024 17:17:19 +0200 Subject: [PATCH] fix encrypted archives bug --- CHANGELOG.md | 14 ++++++++++++++ package.json | 2 +- src/configuration.ts | 1 + src/modules/files/files.service.ts | 11 ++++++----- 4 files changed, 22 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c762e3f..d1c1dc3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,19 @@ # GameVault Backend Server Changelog +## 12.2.0 + +Recommended Gamevault App Version: `v1.11.0.0` + +### Changes + +- Fixed a bug where the indexer would break on password protected archives. [#297](https://github.com/Phalcode/gamevault-backend/issues/297) +- Added Ability to set a default password for game type detection. (`GAMES_DEFAULT_ARCHIVE_PASSWORD`) + +### Thanks + +- @casudo +- @Tere + ## 12.1.3 Recommended Gamevault App Version: `v1.11.0.0` diff --git a/package.json b/package.json index bab6240..2366463 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "gamevault-backend", - "version": "12.1.3", + "version": "12.2.0", "description": "the self-hosted gaming platform for drm-free games", "author": "Alkan Alper, Schäfer Philip GbR / Phalcode", "private": true, diff --git a/src/configuration.ts b/src/configuration.ts index 845646e..a4743e7 100644 --- a/src/configuration.ts +++ b/src/configuration.ts @@ -171,6 +171,7 @@ const configuration = { process.env.SEARCH_RECURSIVE, true, ), + DEFAULT_ARCHIVE_PASSWORD: process.env.GAMES_DEFAULT_ARCHIVE_PASSWORD || "Anything", } as const, IMAGE: { MAX_SIZE_IN_KB: diff --git a/src/modules/files/files.service.ts b/src/modules/files/files.service.ts index 488e555..5199e71 100644 --- a/src/modules/files/files.service.ts +++ b/src/modules/files/files.service.ts @@ -431,13 +431,14 @@ export class FilesService implements OnApplicationBootstrap { const listStream = list(path, { recursive: true, $cherryPick: matchers, + password: configuration.GAMES.DEFAULT_ARCHIVE_PASSWORD, // ANY Password is needed so it doesn't hang up }); listStream.on("data", (data) => executablesList.push(data.file)); listStream.on("error", (error) => { this.logger.error({ - message: `Error extracting executables list. Archive could be corrupted.`, + message: `Error extracting executables list. The archive may be encrypted or corrupted.`, game: { id: undefined, file_path: path }, error, }); @@ -676,17 +677,17 @@ export class FilesService implements OnApplicationBootstrap { ): RangeHeader { let rangeStart = 0; let rangeEnd = fileSize - 1; - + if (rangeHeader?.includes("-")) { const [start, end] = rangeHeader.replace("bytes=", "").split("-"); - + if (start) { const parsedStart = Number(start); if (!isNaN(parsedStart) && parsedStart < fileSize) { rangeStart = parsedStart; } } - + if (end) { const parsedEnd = Number(end); if (!isNaN(parsedEnd) && parsedEnd < fileSize) { @@ -694,7 +695,7 @@ export class FilesService implements OnApplicationBootstrap { } } } - + const rangeSize = rangeEnd - rangeStart + 1; return { start: rangeStart,