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

Commit ad79804

Browse files
committed
feat: integrate ipfs-repo-migrations tool
Related to: #1115
1 parent 607b531 commit ad79804

File tree

7 files changed

+22
-9
lines changed

7 files changed

+22
-9
lines changed

.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'],

README.md

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

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

289301
| Type | Default |

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@
104104
"ipfs-http-response": "~0.4.0",
105105
"ipfs-mfs": "^0.13.0",
106106
"ipfs-multipart": "^0.2.0",
107-
"ipfs-repo": "^0.28.1",
107+
"ipfs-repo": "github:ipfs/js-ipfs-repo#feat/repo-migrations",
108108
"ipfs-unixfs": "~0.1.16",
109109
"ipfs-unixfs-exporter": "^0.38.0",
110110
"ipfs-unixfs-importer": "^0.40.0",

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'])),

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
}

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
}

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)