Skip to content

Commit

Permalink
feat: add option to prevent overwrite recording
Browse files Browse the repository at this point in the history
  • Loading branch information
Laraakaa committed Feb 21, 2024
1 parent ef284ae commit 6ee1024
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 5 deletions.
4 changes: 2 additions & 2 deletions backend/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ log.info(' ');
log.debug('Logging in debug mode!');
log.info('Configuration: ' + JSON.stringify(GlobalContext.commandLine));

const state = new State();
export const state = new State();
const ddragon = new DataDragon(state);
const dataProvider = getDataProvider();
const controller = new Controller({ dataProvider, state, ddragon });
Expand All @@ -50,7 +50,7 @@ const main = async (): Promise<void> => {
await ddragon.init();

const server = http.createServer(app);
app.use('/cache', express.static(__dirname + '/../cache'));
app.use('/cache', express.static('./cache'));
const wsServer = new WebSocketServer(server, state);
wsServer.startHeartbeat();

Expand Down
10 changes: 8 additions & 2 deletions backend/data/league/LeagueDataProviderService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import logger from '../../logging';
import { Session, Cell, Summoner } from '../../types/lcu';

import { CurrentState } from '../CurrentState';
import { state } from '../../app';
import { EventEmitter } from 'events';
import DataProviderService from '../DataProviderService';
import Recorder from '../../recording/Recorder';
Expand All @@ -11,6 +12,7 @@ import Connector, {
LibraryConnector,
ExperimentalConnector,
} from './connector';
import fs from 'fs';
import { Response } from 'league-connect';
const log = logger('LCUDataProviderService');

Expand Down Expand Up @@ -47,8 +49,12 @@ class LeagueDataProviderService extends EventEmitter
this.getCurrentData = this.getCurrentData.bind(this);

if (GlobalContext.commandLine.record) {
this.recorder = new Recorder(GlobalContext.commandLine.record);
log.info('Recording to ' + GlobalContext.commandLine.record);
if (fs.existsSync('../recordings' + '/' + GlobalContext.commandLine.record + '.json') && !state.data.config.overwriteRecording) {
log.error('Recording ' + GlobalContext.commandLine.record + ' already exists. Will not overwrite and therefore not perform recording.')
} else {
this.recorder = new Recorder(GlobalContext.commandLine.record);
log.info('Recording to ' + GlobalContext.commandLine.record);
}
}

this.connector.on('connect', this.onLeagueConnected);
Expand Down
3 changes: 3 additions & 0 deletions backend/package-lock.json

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

4 changes: 4 additions & 0 deletions backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
"version": "0.0.0",
"private": true,
"main": "electron-main.js",
"bin": "./backend-build/app.js",
"pkg": {
"assets": ["node_modules/league-connect/riotgames.pem"]
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "tsc",
Expand Down
2 changes: 1 addition & 1 deletion backend/startTest.bat
Original file line number Diff line number Diff line change
@@ -1 +1 @@
yarn start --data recordings/tournament-draft
yarn start --data ../recordings/tournament-draft
1 change: 1 addition & 0 deletions backend/types/dto/Config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export class Config {
contentPatch = 'latest';
contentCdn = 'https://ddragon.leagueoflegends.com/cdn';
overwriteRecording = true;
}

0 comments on commit 6ee1024

Please sign in to comment.