Skip to content

Commit

Permalink
configs saved with timestamps (#553)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: configs are saved as plain text, no base64 encoding
  • Loading branch information
akosbalasko authored Dec 28, 2023
1 parent 9ab5b44 commit a515fb2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
6 changes: 2 additions & 4 deletions src/ui/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,8 @@ app.whenReady().then(() => {
return
} else if (filePaths) {
const configFilePath = filePaths[0];
const fileContent = fs.readFileSync(configFilePath, {encoding: 'base64'});
let plainConfig = Buffer.from(fileContent, 'base64').toString('utf8')
plainConfig = Buffer.from(plainConfig, 'base64').toString('utf8')
mainWindow.webContents.send('configLoaded', configFilePath, JSON.parse(plainConfig));
const fileContent = fs.readFileSync(configFilePath);
mainWindow.webContents.send('configLoaded', configFilePath, JSON.parse(fileContent));
}

});
Expand Down
7 changes: 5 additions & 2 deletions src/yarle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,11 @@ export const parseStream = async (options: YarleOptions, enexSource: string): Pr
};

const saveOptionsAsConfig = (options: YarleOptions): void => {
const yarleConfigName = 'yarle.config'
const encoded = Buffer.from(JSON.stringify(options), 'utf8').toString('base64')
const now = new Date();
const formattedDateString = `${now.getFullYear()}${String(now.getMonth() + 1).padStart(2, '0')}${String(now.getDate()).padStart(2, '0')}_${String(now.getHours()).padStart(2, '0')}${String(now.getMinutes()).padStart(2, '0')}${String(now.getSeconds()).padStart(2, '0')}`;

const yarleConfigName = `yarle_${formattedDateString}.config`;
const encoded = Buffer.from(JSON.stringify(options))
fs.writeFileSync(path.join(options.outputDir, yarleConfigName), encoded);
}
export const dropTheRope = async (options: YarleOptions): Promise<Array<string>> => {
Expand Down

0 comments on commit a515fb2

Please sign in to comment.