@@ -2,13 +2,7 @@ import { ipcMain, app, BrowserWindow } from 'electron';
22import fs from 'node:fs/promises' ;
33import fsSync from 'node:fs' ;
44import path from 'node:path' ;
5- import crypto from 'crypto' ;
6-
7- function calculateRecipeHash ( recipe : unknown ) : string {
8- const hash = crypto . createHash ( 'sha256' ) ;
9- hash . update ( JSON . stringify ( recipe ) ) ;
10- return hash . digest ( 'hex' ) ;
11- }
5+ import { calculateStableRecipeHash } from './stableRecipeHash' ;
126
137async function getRecipeHashesDir ( ) : Promise < string > {
148 const userDataPath = app . getPath ( 'userData' ) ;
@@ -41,7 +35,7 @@ function isBundledRecipeByTitleAndDescription(recipe: unknown): boolean {
4135}
4236
4337ipcMain . handle ( 'has-accepted-recipe-before' , async ( _event , recipe ) => {
44- const hash = calculateRecipeHash ( recipe ) ;
38+ const hash = calculateStableRecipeHash ( recipe ) ;
4539 const hashFile = path . join ( await getRecipeHashesDir ( ) , `${ hash } .hash` ) ;
4640 try {
4741 await fs . access ( hashFile ) ;
@@ -55,7 +49,7 @@ ipcMain.handle('has-accepted-recipe-before', async (_event, recipe) => {
5549} ) ;
5650
5751ipcMain . handle ( 'record-recipe-hash' , async ( _event , recipe ) => {
58- const hash = calculateRecipeHash ( recipe ) ;
52+ const hash = calculateStableRecipeHash ( recipe ) ;
5953 const filePath = path . join ( await getRecipeHashesDir ( ) , `${ hash } .hash` ) ;
6054 const timestamp = new Date ( ) . toISOString ( ) ;
6155 await fs . writeFile ( filePath , timestamp ) ;
0 commit comments