cosmetic refactor

This commit is contained in:
Andre Staltz 2024-02-21 10:13:29 +02:00
parent 8076007d63
commit fc65557783
No known key found for this signature in database
GPG Key ID: 9EDE23EA7E8A4890
1 changed files with 6 additions and 6 deletions

12
main.js
View File

@ -5,18 +5,18 @@ const p = require('node:util').promisify
const Keypair = require('ppppp-keypair') const Keypair = require('ppppp-keypair')
const awaitable = require('pull-awaitable') const awaitable = require('pull-awaitable')
// WARNING monkey patch! -------------------------------------- // WARNING monkey patch! -------------------------------------------------------
const na = require('sodium-native') const na = require('sodium-native')
na.sodium_malloc = function sodium_malloc_monkey_patched(n) { na.sodium_malloc = function sodium_malloc_monkey_patched(n) {
return Buffer.alloc(n) return Buffer.alloc(n)
} }
na.sodium_free = function sodium_free_monkey_patched() {} na.sodium_free = function sodium_free_monkey_patched() {}
// Electron > 20.3.8 breaks a napi method that `sodium_malloc` // Electron > 20.3.8 breaks a napi method that `sodium_malloc` depends on to
// depends on to create external buffers. (see v8 memory cage) // create external buffers. (see v8 memory cage)
// //
// This crashes electron when called by various libraries, so // This crashes electron when called by various libraries, so we monkey-patch
// we monkey-patch this particular function. // this particular function.
// ------------------------------------------------------------ // -----------------------------------------------------------------------------
process.env.ZOOBOARD_DATA ??= Path.join(app.getPath('appData'), 'zooboard') process.env.ZOOBOARD_DATA ??= Path.join(app.getPath('appData'), 'zooboard')
app.setPath('userData', process.env.ZOOBOARD_DATA) app.setPath('userData', process.env.ZOOBOARD_DATA)