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

Commit

Permalink
feat: integrate ipfs-repo-migrations tool
Browse files Browse the repository at this point in the history
Related to: #1115
  • Loading branch information
AuHau committed Oct 17, 2019
1 parent 09041c3 commit 5b8562d
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .aegir.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const preloadNode = MockPreloadNode.createNode()
const echoServer = EchoServer.createServer()

module.exports = {
bundlesize: { maxSize: '685kB' },
bundlesize: { maxSize: '689kB' },
webpack: {
resolve: {
mainFields: ['browser', 'main'],
Expand Down
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,18 @@ Example:
const node = await IPFS.create({ repo: '/var/ipfs/data' })
```

##### `options.repoAutoMigrate`

| Type | Default |
|------|---------|
| boolean | `true` |

`js-ipfs` comes bundled with tool that automatically migrate the version of your IPFS repository when new version is available.

**For tools that build on top of `js-ipfs` and run mainly in the browser environment, be aware that disabling automatic
migrations leaves the user with no way to run the migrations because there is no CLI in the browser. In such
a case, you should provide a way to trigger migrations manually.**

##### `options.init`

| Type | Default |
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
"ipfs-http-response": "~0.3.1",
"ipfs-mfs": "^0.13.0",
"ipfs-multipart": "^0.2.0",
"ipfs-repo": "^0.28.0",
"ipfs-repo": "github:ipfs/js-ipfs-repo#feat/repo-migrations",
"ipfs-unixfs": "~0.1.16",
"ipfs-unixfs-exporter": "^0.38.0",
"ipfs-unixfs-importer": "^0.40.0",
Expand Down
1 change: 1 addition & 0 deletions src/core/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const s = superstruct({
const configSchema = s({
repo: optional(s('object|string')),
repoOwner: 'boolean?',
repoAutoMigrate: 'boolean?',
preload: s({
enabled: 'boolean?',
addresses: optional(s(['multiaddr'])),
Expand Down
2 changes: 1 addition & 1 deletion src/core/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class IPFS extends EventEmitter {

if (typeof options.repo === 'string' ||
options.repo === undefined) {
this._repo = defaultRepo(options.repo)
this._repo = defaultRepo(options)
} else {
this._repo = options.repo
}
Expand Down
6 changes: 3 additions & 3 deletions src/core/runtime/repo-browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

const IPFSRepo = require('ipfs-repo')

module.exports = (dir) => {
const repoPath = dir || 'ipfs'
return new IPFSRepo(repoPath)
module.exports = (options) => {
const repoPath = options.repo || 'ipfs'
return new IPFSRepo(repoPath, { autoMigrate: options.repoAutoMigrate })
}
6 changes: 3 additions & 3 deletions src/core/runtime/repo-nodejs.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ const os = require('os')
const IPFSRepo = require('ipfs-repo')
const path = require('path')

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

return new IPFSRepo(repoPath)
return new IPFSRepo(repoPath, { autoMigrate: options.repoAutoMigrate })
}

0 comments on commit 5b8562d

Please sign in to comment.