mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
fix(electron): lazy-load before-pack ipfs downloader
This commit is contained in:
@@ -7,7 +7,6 @@ import proxyServer from './proxy-server.js';
|
|||||||
import tcpPortUsed from 'tcp-port-used';
|
import tcpPortUsed from 'tcp-port-used';
|
||||||
import EnvPaths from 'env-paths';
|
import EnvPaths from 'env-paths';
|
||||||
import { fileURLToPath, pathToFileURL } from 'url';
|
import { fileURLToPath, pathToFileURL } from 'url';
|
||||||
import { downloadIpfsClients } from './before-pack.js';
|
|
||||||
const dirname = path.join(path.dirname(fileURLToPath(import.meta.url)));
|
const dirname = path.join(path.dirname(fileURLToPath(import.meta.url)));
|
||||||
const envPaths = EnvPaths('plebbit', { suffix: false });
|
const envPaths = EnvPaths('plebbit', { suffix: false });
|
||||||
|
|
||||||
@@ -23,6 +22,12 @@ const getPlatformDir = () => {
|
|||||||
|
|
||||||
const getBundledKuboPath = (rootPath) => path.join(rootPath, 'bin', getPlatformDir(), getIpfsBinaryName());
|
const getBundledKuboPath = (rootPath) => path.join(rootPath, 'bin', getPlatformDir(), getIpfsBinaryName());
|
||||||
|
|
||||||
|
const downloadBundledIpfsClients = async () => {
|
||||||
|
// before-pack.js is excluded from packaged builds, so only load it in dev.
|
||||||
|
const { downloadIpfsClients } = await import('./before-pack.js');
|
||||||
|
await downloadIpfsClients();
|
||||||
|
};
|
||||||
|
|
||||||
// Resolve kubo binary path
|
// Resolve kubo binary path
|
||||||
const getKuboPath = async () => {
|
const getKuboPath = async () => {
|
||||||
if (isDev) {
|
if (isDev) {
|
||||||
@@ -36,7 +41,7 @@ const getKuboPath = async () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
console.log(`Kubo binary missing at ${bundledKuboPath}, downloading repo-managed binary...`);
|
console.log(`Kubo binary missing at ${bundledKuboPath}, downloading repo-managed binary...`);
|
||||||
await downloadIpfsClients();
|
await downloadBundledIpfsClients();
|
||||||
|
|
||||||
if (fs.existsSync(bundledKuboPath)) {
|
if (fs.existsSync(bundledKuboPath)) {
|
||||||
return bundledKuboPath;
|
return bundledKuboPath;
|
||||||
|
|||||||
Reference in New Issue
Block a user