From 3c85f8e197b4d11b8f8a366aa1e89a4d4c3a0ee0 Mon Sep 17 00:00:00 2001 From: Alper Alkan Date: Sun, 24 Dec 2023 03:59:12 +0100 Subject: [PATCH] fix detecting invalid file names for directories --- CHANGELOG.md | 10 ++++++++++ package.json | 2 +- src/modules/files/files.service.spec.ts | 2 +- src/modules/files/files.service.ts | 8 +++++--- 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a7df9766..43d3e475 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,15 @@ # GameVault Backend Server Changelog +## 10.0.1 + +### Changes + +- Fixed Server detecting invalid file names for games in subdirectories + +### Thanks + +- @Kudjo + ## 10.0.0 Recommended Gamevault App Version: `v1.8.0` diff --git a/package.json b/package.json index 7b5bdff0..667d470e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "gamevault-backend", - "version": "10.0.0", + "version": "10.0.1", "description": "the self-hosted gaming platform for drm-free games", "author": "Alkan Alper, Schäfer Philip GbR / Phalcode", "private": true, diff --git a/src/modules/files/files.service.spec.ts b/src/modules/files/files.service.spec.ts index 844c3974..650322df 100644 --- a/src/modules/files/files.service.spec.ts +++ b/src/modules/files/files.service.spec.ts @@ -91,7 +91,7 @@ describe("FilesService", () => { const validFilenames = [ "Star Wars Jedi - Fallen Order (v1.0.10.0) (2019).zip", "HITMAN 3 (v3.10.1) (2021).7z", - "The Wandering Village (v0.1.32) (EA) (2022).iso", + "!mygames/!The Wandering Village (v0.1.32) (EA) (2022).iso", "Saints Row (W_S) (2022).zip", "My personal IndieGame (v1.2.9) (NC) (2018).zip", "Stray (2022).7z", diff --git a/src/modules/files/files.service.ts b/src/modules/files/files.service.ts index 4cffa7cc..d4a35812 100644 --- a/src/modules/files/files.service.ts +++ b/src/modules/files/files.service.ts @@ -42,7 +42,7 @@ export class FilesService implements OnApplicationBootstrap { private gamesService: GamesService, private rawgService: RawgService, private boxartService: BoxArtsService, - ) {} + ) { } onApplicationBootstrap() { this.checkFolders(); @@ -158,10 +158,11 @@ export class FilesService implements OnApplicationBootstrap { private isValidFilename(filename: string) { const invalidCharacters = /[\/<>:"\\|?*]/; + const actualFilename = basename(filename); if ( !configuration.GAMES.SUPPORTED_FILE_FORMATS.includes( - extname(filename).toLowerCase(), + extname(actualFilename).toLowerCase(), ) ) { this.logger.debug( @@ -170,7 +171,7 @@ export class FilesService implements OnApplicationBootstrap { return false; } - if (invalidCharacters.test(filename)) { + if (invalidCharacters.test(actualFilename)) { this.logger.warn( `Indexer ignoring invalid filename: contains invalid characters - ${filename}`, ); @@ -180,6 +181,7 @@ export class FilesService implements OnApplicationBootstrap { return true; } + /** * This method extracts the game title from a given file name string using a * regular expression.