From e50431d27c0395849b12159481d5e5f0f04be242 Mon Sep 17 00:00:00 2001 From: Paul Frazee Date: Wed, 10 Jul 2019 16:51:59 -0500 Subject: [PATCH] WIP - Move to the new hyperdrive daemon --- app/background-process.js | 6 +----- app/background-process/ui/permissions.js | 2 +- app/background-process/ui/view-manager.js | 7 ++++--- app/dat-daemon.js | 20 -------------------- 4 files changed, 6 insertions(+), 29 deletions(-) delete mode 100644 app/dat-daemon.js diff --git a/app/background-process.js b/app/background-process.js index a7cba9d900..82c1920742 100644 --- a/app/background-process.js +++ b/app/background-process.js @@ -85,9 +85,6 @@ app.on('open-file', (e, filepath) => { }) app.on('ready', async function () { - // start the daemon process - var datDaemonProcess = await childProcesses.spawn('dat-daemon', './dat-daemon.js') - portForwarder.setup() // setup core @@ -109,8 +106,7 @@ app.on('ready', async function () { }, rpcAPI: rpc, downloadsWebAPI: downloads.WEBAPI, - browserWebAPI: beakerBrowser.WEBAPI, - datDaemonProcess + browserWebAPI: beakerBrowser.WEBAPI }) // base diff --git a/app/background-process/ui/permissions.js b/app/background-process/ui/permissions.js index a44b63cf06..ebe19d167b 100644 --- a/app/background-process/ui/permissions.js +++ b/app/background-process/ui/permissions.js @@ -76,7 +76,7 @@ export async function checkLabsPerm ({perm, labApi, apiDocsUrl, sender}) { let isOptedIn = false let archive = dat.library.getArchive(key) if (archive) { - let {checkoutFS} = dat.library.getArchiveCheckout(archive, urlp.version) + let {checkoutFS} = await dat.library.getArchiveCheckout(archive, urlp.version) let manifest = await pda.readManifest(checkoutFS).catch(_ => {}) let apis = _get(manifest, 'experimental.apis') if (apis && Array.isArray(apis)) { diff --git a/app/background-process/ui/view-manager.js b/app/background-process/ui/view-manager.js index 05c88dd512..bc44fcb60f 100644 --- a/app/background-process/ui/view-manager.js +++ b/app/background-process/ui/view-manager.js @@ -489,11 +489,12 @@ class View { // live reloading // = - toggleLiveReloading (enable) { + + async toggleLiveReloading (enable) { if (typeof enable === 'undefined') { enable = !this.liveReloadEvents } - if (!enable) { + if (this.liveReloadEvents) { this.liveReloadEvents.close() this.liveReloadEvents = false } else if (this.datInfo) { @@ -501,7 +502,7 @@ class View { if (!archive) return let {version} = parseDatURL(this.url) - let {checkoutFS} = beakerCore.dat.library.getArchiveCheckout(archive, version) + let {checkoutFS} = await beakerCore.dat.library.getArchiveCheckout(archive, version) this.liveReloadEvents = checkoutFS.pda.watch() let event = (this.datInfo.isOwner) ? 'changed' : 'invalidated' diff --git a/app/dat-daemon.js b/app/dat-daemon.js deleted file mode 100644 index 400068bfc1..0000000000 --- a/app/dat-daemon.js +++ /dev/null @@ -1,20 +0,0 @@ -const {join} = require('path') -const rpcAPI = require('pauls-electron-rpc') -const beakerCoreDatDaemon = require('@beaker/core/dat/daemon') - -process.on('uncaughtException', (err) => { - console.error('Uncaught exception:', err) -}) - -process.on('disconnect', () => { - process.exit() -}) - -process.once('message', firstMsg => { - beakerCoreDatDaemon.setup({ - rpcAPI, - logfilePath: join(firstMsg.userDataPath, 'dat.log') - }) - process.send({ready: true}) - console.log('dat-daemon ready') -}) \ No newline at end of file