Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
case "slippi:":
const tmpDir = os.tmpdir();
const destination = path.join(tmpDir, 'replay.slp');
const replayPath = myUrl.searchParams.get('path');
// The following path generation will not work on dev
// __static didn't exist and __dirname didn't work. /shrug
const appPath = app.getAppPath();
const keyPath = path.join(appPath, "../app.asar.unpacked/static/storage-reader.json");
log.info(`Keypath: ${keyPath}`);
const storage = new Storage({
projectId: 'slippi',
keyFilename: keyPath,
});
const bucket = storage.bucket('slippi.appspot.com');
const file = new File(bucket, replayPath);
log.info(`Downloading file ${replayPath} to ${destination}`);
// Dowload file
await file.download({ destination: destination });
log.info(`Finished download`);
// Wait until mainWindow exists so that we can send an IPC to play.
// We are willing to wait for a few seconds before timing out
await waitForMainWindow();
mainWindow.webContents.send("play-replay", path.join(tmpDir, 'replay.slp'));
break;
case "file:":