Skip to content

Commit

Permalink
Use constructed path
Browse files Browse the repository at this point in the history
  • Loading branch information
colin969 committed Apr 19, 2024
1 parent 4031c13 commit 5a69bc6
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/ext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,19 @@ export async function activate(context: flashpoint.ExtensionContext) {
}

flashpoint.games.onWillUninstallGameData(async (gameData) => {
const filePath: string = path.resolve(path.join(dataPacksPath, gameData.path));
flashpoint.log.debug(`Unmounting Game Data: \"${gameData.path}\"`);
const filename = getGameDataFilename(gameData);
const filePath: string = path.resolve(path.join(dataPacksPath, filename));
flashpoint.log.debug(`Unmounting Game Data: \"${filename}\"`);
return unmountGame(filePath);
});

flashpoint.games.onWillLaunchGame(async (gameLaunchInfo) => {
if (gameLaunchInfo.activeData) {
if (gameLaunchInfo.activeData.presentOnDisk) {
// Data present, mount it now
const filename = getGameDataFilename(gameLaunchInfo.activeData);
flashpoint.log.debug("GameData present on disk, mounting...");
const filePath: string = path.resolve(path.join(dataPacksPath, gameLaunchInfo.activeData.path));
const filePath: string = path.resolve(path.join(dataPacksPath, filename));
flashpoint.log.debug(`Mount parameters: \"${gameLaunchInfo.activeData.parameters}\"`);
if (gameLaunchInfo.activeData.parameters?.startsWith("-extract")) {
flashpoint.log.debug("AutoMount skipping, '-extract' registered.");
Expand All @@ -57,8 +59,9 @@ export async function activate(context: flashpoint.ExtensionContext) {
const activeData = await flashpoint.gameData.findOne(addAppInfo.parentGame.activeDataId)
if (activeData && activeData.presentOnDisk) {
// Data present, mount it now
const filename = getGameDataFilename(activeData);
flashpoint.log.debug("GameData present on disk, mounting...");
const filePath: string = path.resolve(path.join(dataPacksPath, activeData.path));
const filePath: string = path.resolve(path.join(dataPacksPath, filename));
flashpoint.log.debug(`Mount parameters: \"${activeData.parameters}\"`);
if (activeData.parameters?.startsWith("-extract")) {
flashpoint.log.debug("AutoMount skipping, '-extract' registered.");
Expand All @@ -76,3 +79,7 @@ export async function activate(context: flashpoint.ExtensionContext) {
}
});
};

export function getGameDataFilename(data: flashpoint.GameData) {
return `${data.gameId}-${(new Date(data.dateAdded)).getTime()}.zip`;
}

0 comments on commit 5a69bc6

Please sign in to comment.