Skip to content

Commit

Permalink
fix encrypted archives bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Alfagun74 committed Jun 21, 2024
1 parent 6b14d8a commit 00a9401
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 6 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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`
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
1 change: 1 addition & 0 deletions src/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
11 changes: 6 additions & 5 deletions src/modules/files/files.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});
Expand Down Expand Up @@ -676,25 +677,25 @@ 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) {
rangeEnd = parsedEnd >= rangeStart ? parsedEnd : rangeEnd;
}
}
}

const rangeSize = rangeEnd - rangeStart + 1;
return {
start: rangeStart,
Expand Down

0 comments on commit 00a9401

Please sign in to comment.