Skip to content

Commit

Permalink
Unmount game before uninstalling game data
Browse files Browse the repository at this point in the history
  • Loading branch information
colin969 committed Oct 16, 2023
1 parent 662b14e commit 4031c13
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/ext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,31 @@ export async function activate(context: flashpoint.ExtensionContext) {
const fpPath: string = flashpoint.config.flashpointPath;
const dataPacksPath: string = path.join(fpPath, flashpoint.getPreferences().dataPacksFolderPath);

async function unmountGame(filePath: string) {
return axios.post("http://localhost:22501/fpProxy/api/unmountzip", {
filePath
})
.catch((err: any) => {
flashpoint.log.error(`Failed to mount zip: ${filePath} - ${err}`);
});
}

// Mount a game, if applicable.
async function mountGame(filePath: string) {
return axios.post("http://localhost:22501/fpProxy/api/mountzip", {
filePath
})
.catch((err) => {
.catch((err: any) => {
flashpoint.log.error(`Failed to mount zip: ${filePath} - ${err}`);
});
}

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

flashpoint.games.onWillLaunchGame(async (gameLaunchInfo) => {
if (gameLaunchInfo.activeData) {
if (gameLaunchInfo.activeData.presentOnDisk) {
Expand Down

0 comments on commit 4031c13

Please sign in to comment.