Skip to content
This repository was archived by the owner on Feb 12, 2024. It is now read-only.

Commit 5b8562d

Browse files
committed
feat: integrate ipfs-repo-migrations tool
Related to: #1115
1 parent 09041c3 commit 5b8562d

File tree

7 files changed

+22
-9
lines changed

7 files changed

+22
-9
lines changed

Diff for: .aegir.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const preloadNode = MockPreloadNode.createNode()
1010
const echoServer = EchoServer.createServer()
1111

1212
module.exports = {
13-
bundlesize: { maxSize: '685kB' },
13+
bundlesize: { maxSize: '689kB' },
1414
webpack: {
1515
resolve: {
1616
mainFields: ['browser', 'main'],

Diff for: README.md

+12
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,18 @@ Example:
283283
const node = await IPFS.create({ repo: '/var/ipfs/data' })
284284
```
285285

286+
##### `options.repoAutoMigrate`
287+
288+
| Type | Default |
289+
|------|---------|
290+
| boolean | `true` |
291+
292+
`js-ipfs` comes bundled with tool that automatically migrate the version of your IPFS repository when new version is available.
293+
294+
**For tools that build on top of `js-ipfs` and run mainly in the browser environment, be aware that disabling automatic
295+
migrations leaves the user with no way to run the migrations because there is no CLI in the browser. In such
296+
a case, you should provide a way to trigger migrations manually.**
297+
286298
##### `options.init`
287299

288300
| Type | Default |

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@
103103
"ipfs-http-response": "~0.3.1",
104104
"ipfs-mfs": "^0.13.0",
105105
"ipfs-multipart": "^0.2.0",
106-
"ipfs-repo": "^0.28.0",
106+
"ipfs-repo": "github:ipfs/js-ipfs-repo#feat/repo-migrations",
107107
"ipfs-unixfs": "~0.1.16",
108108
"ipfs-unixfs-exporter": "^0.38.0",
109109
"ipfs-unixfs-importer": "^0.40.0",

Diff for: src/core/config.js

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ const s = superstruct({
2828
const configSchema = s({
2929
repo: optional(s('object|string')),
3030
repoOwner: 'boolean?',
31+
repoAutoMigrate: 'boolean?',
3132
preload: s({
3233
enabled: 'boolean?',
3334
addresses: optional(s(['multiaddr'])),

Diff for: src/core/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ class IPFS extends EventEmitter {
7070

7171
if (typeof options.repo === 'string' ||
7272
options.repo === undefined) {
73-
this._repo = defaultRepo(options.repo)
73+
this._repo = defaultRepo(options)
7474
} else {
7575
this._repo = options.repo
7676
}

Diff for: src/core/runtime/repo-browser.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
const IPFSRepo = require('ipfs-repo')
44

5-
module.exports = (dir) => {
6-
const repoPath = dir || 'ipfs'
7-
return new IPFSRepo(repoPath)
5+
module.exports = (options) => {
6+
const repoPath = options.repo || 'ipfs'
7+
return new IPFSRepo(repoPath, { autoMigrate: options.repoAutoMigrate })
88
}

Diff for: src/core/runtime/repo-nodejs.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ const os = require('os')
44
const IPFSRepo = require('ipfs-repo')
55
const path = require('path')
66

7-
module.exports = (dir) => {
8-
const repoPath = dir || path.join(os.homedir(), '.jsipfs')
7+
module.exports = (options) => {
8+
const repoPath = options.repo || path.join(os.homedir(), '.jsipfs')
99

10-
return new IPFSRepo(repoPath)
10+
return new IPFSRepo(repoPath, { autoMigrate: options.repoAutoMigrate })
1111
}

0 commit comments

Comments
 (0)