Skip to content

Commit e01d723

Browse files
committed
more work on versions
1 parent a44890d commit e01d723

4 files changed

Lines changed: 29 additions & 17 deletions

File tree

src/modules/games/files.service.ts

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,10 @@ export class FilesService implements OnApplicationBootstrap {
7171
async onApplicationBootstrap() {
7272
if (configuration.TESTING.MOCK_FILES) {
7373
this.logger.warn({
74-
message: "Skipping File Indexer.",
74+
message: "Skipping File Watcher.",
7575
reason: "TESTING_MOCK_FILES is set to true.",
7676
});
77+
this.indexAllFiles();
7778
return;
7879
}
7980

@@ -389,16 +390,21 @@ export class FilesService implements OnApplicationBootstrap {
389390

390391
const selectedVersion = selectDefaultGameVersion(availableVersions);
391392

392-
this.applyVersionToGame(gameToUpdate, selectedVersion);
393-
gameToUpdate.title = indexedGame.title;
394-
gameToUpdate.sort_title = this.gamesService.generateSortTitle(
393+
const gamePatch = Object.assign(new GamevaultGame(), { id });
394+
this.applyVersionToGame(gamePatch, selectedVersion);
395+
gamePatch.title = indexedGame.title;
396+
gamePatch.sort_title = this.gamesService.generateSortTitle(
395397
indexedGame.title,
396398
);
397399

398-
const updatedGame = await this.gamesService.save(gameToUpdate);
400+
// Persist only scalar game fields to avoid relation graph side effects.
401+
await this.gamesService.save(gamePatch);
402+
const updatedGame = await this.gamesService.findOneByGameIdOrFail(id, {
403+
loadDeletedEntities: false,
404+
});
399405
this.logger.log({
400406
message: `Updated game versions based on file changes.`,
401-
game: logGamevaultGame(gameToUpdate),
407+
game: logGamevaultGame(updatedGame),
402408
});
403409
return updatedGame;
404410
}
@@ -932,16 +938,13 @@ export class FilesService implements OnApplicationBootstrap {
932938
await this.gameVersionRepository.softDelete(staleVersionIds);
933939
}
934940

935-
const gameToUpdate = await this.gamesService.findOneByGameIdOrFail(
936-
gameInDatabase.id,
937-
{
938-
loadDeletedEntities: false,
939-
},
940-
);
941-
942941
const selectedVersion = selectDefaultGameVersion(existingVersions);
943-
this.applyVersionToGame(gameToUpdate, selectedVersion);
944-
await this.gamesService.save(gameToUpdate);
942+
const gamePatch = Object.assign(new GamevaultGame(), {
943+
id: gameInDatabase.id,
944+
});
945+
this.applyVersionToGame(gamePatch, selectedVersion);
946+
// Persist only scalar game fields to avoid relation graph side effects.
947+
await this.gamesService.save(gamePatch);
945948
}
946949

947950
checkedGames.push(gameInDatabase);

src/modules/games/game-version.entity.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ export class GameVersion extends DatabaseEntity {
7676
})
7777
type: GameType;
7878

79-
@Column({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
79+
@Column({ default: new Date() })
8080
@ApiProperty({
8181
description: "timestamp when this version was indexed",
8282
example: "2026-02-15T12:00:00.000Z",

src/modules/web-ui/web-ui.module.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Module, OnModuleInit } from "@nestjs/common";
1+
import { Logger, Module, OnModuleInit } from "@nestjs/common";
22
import { ServeStaticModule } from "@nestjs/serve-static";
33
import { join, resolve } from "path";
44
import configuration from "../../configuration";
@@ -14,9 +14,14 @@ import { WebUIService } from "./web-ui.service";
1414
],
1515
})
1616
export class WebUIModule implements OnModuleInit {
17+
private readonly logger = new Logger(this.constructor.name);
1718
constructor(private readonly webUIService: WebUIService) {}
1819

1920
async onModuleInit() {
21+
this.logger.log({
22+
message: "Initializing WebUIModule",
23+
rootPath: resolve(join(configuration.VOLUMES.CONFIG, "frontend", "dist")),
24+
});
2025
await this.webUIService.prepareFrontend();
2126
}
2227
}

src/modules/web-ui/web-ui.service.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ export class WebUIService {
4141
message: "Preparing frontend",
4242
serverVersion,
4343
forcedVersion,
44+
cachePath: this.cachePath,
4445
});
4546

4647
await fs.ensureDir(this.cachePath);
@@ -57,18 +58,21 @@ export class WebUIService {
5758
this.logger.log({
5859
message: "Using cached frontend version",
5960
version: this.compatibleVersion,
61+
cachePath: this.cachePath,
6062
});
6163
} else {
6264
this.logger.log({
6365
message: "Cached frontend not found, downloading",
6466
version: this.compatibleVersion,
67+
cachePath: this.cachePath,
6568
});
6669
await this.ensureFrontendCached(this.compatibleVersion);
6770
}
6871

6972
this.logger.log({
7073
message: "Frontend is ready",
7174
version: this.compatibleVersion,
75+
cachePath: this.cachePath,
7276
});
7377
} catch (error) {
7478
this.logger.error("Error fetching or preparing frontend", error);

0 commit comments

Comments
 (0)