Skip to content

Commit

Permalink
Merge branch 'hotfix/12.1.0' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
colin969 committed Sep 30, 2023
2 parents eaf9fbb + a921a28 commit 6ee057a
Show file tree
Hide file tree
Showing 23 changed files with 317 additions and 110 deletions.
1 change: 1 addition & 0 deletions .github/workflows/nexus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
- master
- develop
- 'release/**'
- 'hotfix/**'

jobs:
build:
Expand Down
7 changes: 6 additions & 1 deletion lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,7 @@
"noVersion": "No Version",
"releaseDate": "Release Date",
"noReleaseDate": "No Release Date",
"noneFound": "None Found",
"language": "Language",
"noLanguage": "No Language",
"dateAdded": "Date Added",
Expand Down Expand Up @@ -342,6 +343,7 @@
"saveChanges": "Save Changes",
"discardChanges": "Discard Changes",
"editFpfssGame": "Edit Game (FPFSS)",
"showOnFpfss": "Show Game on FPFSS",
"editGame": "Edit Game",
"allGames": "All Games",
"newPlaylist": "New Playlist",
Expand All @@ -362,7 +364,10 @@
"noMountParameters": "No Mount Parameters",
"showExtremeScreenshot": "Show Extreme Screenshot",
"busy": "Please Wait...",
"openGameDataBrowser": "Open Game Data Browser"
"openGameDataBrowser": "Open Game Data Browser",
"notArchived": "Not Archived",
"archived": "Archived",
"playOnline": "Play Online"
},
"tags": {
"name": "Name",
Expand Down
30 changes: 7 additions & 23 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "flashpoint-launcher",
"version": "12.0.0",
"version": "12.1.0",
"description": "A desktop application used to browse, manage and play games from Flashpoint Archive",
"main": "build/main/index.js",
"config": {
Expand Down
9 changes: 7 additions & 2 deletions src/back/GameLauncher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -525,13 +525,18 @@ async function handleGameDataParams(opts: LaunchBaseOpts, serverOverride?: strin
alreadyExtracted = fs.existsSync(filePath);
}
if (!alreadyExtracted) {
// Extra game data to htdocs folder
// Extract game data to htdocs folder
const gameDataPath = path.join(opts.fpPath, opts.dataPacksFolderPath, gameData.path || '');
const tempPath = path.join(opts.fpPath, '.temp', 'extract');
await fs.ensureDir(tempPath);
const destPath = path.join(opts.fpPath, opts.htdocsPath);
log.debug('Launcher', `Extracting game data from "${gameDataPath}" to "${tempPath}"`);
await extractFullPromise([gameDataPath, tempPath, { $bin: opts.sevenZipPath }]);
await extractFullPromise([gameDataPath, tempPath, { $bin: opts.sevenZipPath }])
.catch((err) => {
console.log(err);
log.error('Launcher', `Failed to extract game data: ${err}`);
throw err;
});
const contentFolder = path.join(tempPath, 'content');
// Move contents of contentFolder to destPath
log.debug('Launcher', `Moving extracted game data from "${contentFolder}" to "${destPath}"`);
Expand Down
4 changes: 2 additions & 2 deletions src/back/ManagedChildProcess.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { IBackProcessInfo, INamedBackProcessInfo, ProcessState } from '@shared/interfaces';
import { ILogPreEntry } from '@shared/Log/interface';
import { IBackProcessInfo, INamedBackProcessInfo, ProcessState } from '@shared/interfaces';
import * as Coerce from '@shared/utils/Coerce';
import { ChildProcess, spawn } from 'child_process';
import { EventEmitter } from 'events';
Expand Down Expand Up @@ -112,7 +112,7 @@ export class ManagedChildProcess extends EventEmitter {
}
// Spawn process
log.debug('Server', `Arguments: ${this.info.arguments.join('; ')}`);
this.process = spawn(this.info.filename, this.info.arguments, { cwd: this.cwd, detached: this.detached, shell: this.shell , env: this.env});
this.process = spawn(this.info.filename, this.info.arguments, { cwd: this.cwd, detached: this.detached, shell: this.shell, env: this.env});
// Set start timestamp
this.startTime = Date.now();
// Log
Expand Down
33 changes: 21 additions & 12 deletions src/back/game/GameDataManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ export async function downloadGameData(gameDataId: number, dataPacksFolderPath:
const sourceErrors: string[] = [];
log.debug('Game Launcher', `Checking ${sources.length} Sources for this GameData...`);
if (gameData) {
if (gameData.presentOnDisk) { return; }
// GameData real, find an available source
for (const source of sources) {
try {
Expand All @@ -36,9 +35,19 @@ export async function downloadGameData(gameDataId: number, dataPacksFolderPath:
if (sha256.toLowerCase() !== gameData.sha256.toLowerCase()) {
reject('Hash of download does not match! Download aborted.\n (It may be a corrupted download, try again)');
} else {
await importGameDataSkipHash(gameData.gameId, tempPath, dataPacksFolderPath, sha256);
await fs.promises.unlink(tempPath);
resolve();
try {
log.debug('Game Launcher', 'Validated game data, importing to games folder');
await importGameDataSkipHash(gameData.gameId, tempPath, dataPacksFolderPath, sha256, gameData)
.catch((err) => {
console.log(`Error importing game data ${err}`);
log.error('Launcher', 'Error importing game data ' + err);
throw err;
});
await fs.promises.unlink(tempPath);
resolve();
} catch (err) {
reject(err);
}
}
});
stream.pipe(hash);
Expand Down Expand Up @@ -80,23 +89,23 @@ export async function remove(gameDataId: number): Promise<void> {
await gameDataRepository.delete({ id: gameDataId });
}

export async function importGameDataSkipHash(gameId: string, filePath: string, dataPacksFolderPath: string, sha256: string): Promise<GameData> {
export async function importGameDataSkipHash(gameId: string, filePath: string, dataPacksFolderPath: string, sha256: string, existingGameData?: GameData): Promise<GameData> {
await fs.promises.access(filePath, fs.constants.F_OK);
// Gather basic info
const stats = await fs.promises.stat(filePath);
const gameData = await findGameData(gameId);
const existingGameData = gameData.find(g => g.sha256.toLowerCase() === sha256.toLowerCase());
if (!existingGameData) {
const gameData = await findGameData(gameId);
existingGameData = gameData.find(g => g.sha256.toLowerCase() === sha256.toLowerCase());
}
// Copy file
const dateAdded = new Date();
const newFilename = existingGameData ? `${gameId}-${existingGameData.dateAdded.getTime()}.zip` : `${gameId}-${dateAdded.getTime()}.zip`;
const newPath = path.join(dataPacksFolderPath, newFilename);
await fs.promises.copyFile(filePath, newPath);
if (existingGameData) {
if (existingGameData.presentOnDisk === false) {
existingGameData.path = newFilename;
existingGameData.presentOnDisk = true;
return save(existingGameData);
}
existingGameData.path = newFilename;
existingGameData.presentOnDisk = true;
return save(existingGameData);
} else {
const newGameData = new GameData();
newGameData.title = 'Data Pack';
Expand Down
9 changes: 5 additions & 4 deletions src/back/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,15 @@ import { GDIndex1680813346696 } from '@database/migration/1680813346696-GDIndex'
import { MoveLaunchPath1681561150000 } from '@database/migration/1681561150000-MoveLaunchPath';
import { PrimaryPlatform1684673859425 } from '@database/migration/1684673859425-PrimaryPlatform';
import { PlayTime1687807237714 } from '@database/migration/1687807237714-PlayTime';
import { PlayTimeIndices1687847922729 } from '@database/migration/1687847922729-PlayTimeIndices';
import { ArchiveState1689423335642 } from '@database/migration/1689423335642-ArchiveState';
import {
CURATIONS_FOLDER_EXPORTED,
CURATIONS_FOLDER_EXTRACTING,
CURATIONS_FOLDER_TEMP,
CURATIONS_FOLDER_WORKING, CURATION_META_FILENAMES
} from '@shared/constants';
import axios from 'axios';
import { Tail } from 'tail';
import { DataSource, DataSourceOptions } from 'typeorm';
import { ConfigFile } from './ConfigFile';
Expand Down Expand Up @@ -93,8 +96,6 @@ import { LogFile } from './util/LogFile';
import { logFactory } from './util/logging';
import { createContainer, exit, getMacPATH, runService } from './util/misc';
import { uuid } from './util/uuid';
import { PlayTimeIndices1687847922729 } from '@database/migration/1687847922729-PlayTimeIndices';
import axios from 'axios';

const dataSourceOptions: DataSourceOptions = {
type: 'better-sqlite3',
Expand All @@ -103,7 +104,7 @@ const dataSourceOptions: DataSourceOptions = {
migrations: [Initial1593172736527, AddExtremeToPlaylist1599706152407, GameData1611753257950, SourceDataUrlPath1612434225789, SourceFileURL1612435692266,
SourceFileCount1612436426353, GameTagsStr1613571078561, GameDataParams1619885915109, RemoveSources1676712700000, RemovePlaylist1676713895000,
TagifyPlatform1677943090621, AddPlatformsRedundancyFieldToGame1677951346785, GDIndex1680813346696, MoveLaunchPath1681561150000,
PrimaryPlatform1684673859425, PlayTime1687807237714, PlayTimeIndices1687847922729
PrimaryPlatform1684673859425, PlayTime1687807237714, PlayTimeIndices1687847922729, ArchiveState1689423335642
]
};
export let AppDataSource: DataSource = new DataSource(dataSourceOptions);
Expand Down Expand Up @@ -992,7 +993,7 @@ async function initialize() {
for (let i = 0; i < state.serviceInfo.daemon.length; i++) {
const service = state.serviceInfo.daemon[i];
const id = 'daemon_' + i;
runService(state, id, service.name || id, state.config.flashpointPath, {}, service);
runService(state, id, service.name || id, state.config.flashpointPath, { detached: !service.kill, noshell: !!service.kill }, service);
}
// Start file watchers
for (let i = 0; i < state.serviceInfo.watch.length; i++) {
Expand Down
3 changes: 2 additions & 1 deletion src/back/responses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,7 @@ export function registerRequestCallbacks(state: BackState, init: () => Promise<v
log.debug('Launcher', 'Found active game data');
gameData = await GameDataManager.findOne(game.activeDataId);
if (gameData && !gameData.presentOnDisk) {
log.debug('Game Launcher', 'Downloading Game Data for ' + gameData.path || 'UNKNOWN');
// Download GameData
try {
await downloadGameData(state, gameData);
Expand Down Expand Up @@ -1705,7 +1706,7 @@ export function registerRequestCallbacks(state: BackState, init: () => Promise<v
const updatesReady = state.componentStatuses.filter(c => c.state === ComponentState.NEEDS_UPDATE).length > 0;
exitApp(state, async () => {
const args = updatesReady ? ['/update', '/launcher'] : ['/launcher'];
const child = child_process.spawn(fpmPath, args, { detached: true, cwd, stdio: ['ignore', 'ignore', 'ignore'] });
const child = child_process.spawn(fpmPath, args, { detached: true, shell: true, cwd, stdio: ['ignore', 'ignore', 'ignore'] });
child.unref();
});
});
Expand Down
5 changes: 4 additions & 1 deletion src/back/sync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,8 @@ export async function syncGames(tx: EntityManager, source: GameMetadataSource, d
language: changedGame.language,
library: changedGame.library,
activeDataId: -1,
platformName: changedGame.platform_name
platformName: changedGame.platform_name,
archiveState: changedGame.archive_state
}).where({ id: changedGame.id }).execute();
}

Expand Down Expand Up @@ -387,6 +388,7 @@ export async function syncGames(tx: EntityManager, source: GameMetadataSource, d
activeDataId: -1,
activeDataOnDisk: false,
platformName: newGame.platform_name,
archiveState: newGame.archive_state,
});
await gamesRepo.save(g);
}
Expand Down Expand Up @@ -533,6 +535,7 @@ type RemoteGame = {
language: string;
library: string;
platform_name: string;
archive_state: number;
}

type RemoteTagRaw = {
Expand Down
Loading

0 comments on commit 6ee057a

Please sign in to comment.