ipfs improvements:

- fix ipfs for apple m1 osx builds by adding extra binary prebuilds (for now)
- use <profile directory>/js-ipfs for ipfs repo
- update to js-ipfs 0.10.6
bump to 1.5.2
This commit is contained in:
Ilya Kreymer
2021-09-13 07:31:37 -07:00
parent 589ea5ddd4
commit d341c03350
9 changed files with 2561 additions and 3445 deletions
+13 -3
View File
@@ -33,13 +33,18 @@ let IPFS = null;
// ============================================================================
class NativeIPFSClient extends IPFSClient
{
constructor(repoPath) {
super();
this.repoPath = repoPath;
}
async _doInitIPFS() {
if (!IPFS) {
IPFS = require("ipfs-core");
}
this.ipfs = await IPFS.create({
//repo: "/tmp/test-ipfs"
repo: this.repoPath,
init: {emptyRepo: true},
//preload: {enabled: false},
});
@@ -72,7 +77,7 @@ class ElectronReplayApp
this.screenSize = {width: 1024, height: 768};
this.ipfsClient = new NativeIPFSClient();
this.ipfsClient = null;
}
get mainWindowWebPreferences() {
@@ -140,6 +145,11 @@ class ElectronReplayApp
app.setPath("userData", path.join(app.getPath("appData"), this.profileName));
}
const ipfsRepoPath = path.join(app.getPath("userData"), "js-ipfs");
console.log("ipfs path", ipfsRepoPath);
this.ipfsClient = new NativeIPFSClient(ipfsRepoPath);
app.on("will-finish-launching", () => {
app.on("open-file", (event, filePath) => {
this.openNextFile = filePath;
@@ -300,7 +310,7 @@ class ElectronReplayApp
if (request.method === "GET") {
const offset = start || 0;
const length = end ? end - start + 1 : size;
data = Readable.from(this.ipfsClient.cat(ipfsCID, {offset, length}));
data = Readable.from(await this.ipfsClient.cat(ipfsCID, {offset, length}));
}
callback({statusCode, headers, data});