-
Notifications
You must be signed in to change notification settings - Fork 98
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes to data directory #448
Merged
Merged
Changes from 7 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
1965ce2
Use data directory based on network name, e.g. '~/.cosmos/gaia-2'
mappum 3438f23
Error and exit if we have existing incompatible data, removes need to…
mappum 66b0a0e
Throw instead of exiting process
mappum 6059a0c
Updated main tests for new behavior of data dir changes
mappum 4e1a3e2
Merge branch 'develop' into matt/372-data-dir
nylira e9c6ee5
Added root path test
mappum 77e54e9
Merge branch 'develop' into matt/372-data-dir
mappum 19ef8d8
Merge branch 'develop' into matt/372-data-dir
jbibla File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
let { join } = require('path') | ||
let { readFileSync } = require('fs') | ||
|
||
// this network gets used if none is specified via the | ||
// COSMOS_NETWORK env var | ||
let DEFAULT_NETWORK = join(__dirname, '../networks/gaia-2') | ||
let networkPath = process.env.COSMOS_NETWORK || DEFAULT_NETWORK | ||
|
||
let genesisText = readFileSync(join(networkPath, 'genesis.json'), 'utf8') | ||
let genesis = JSON.parse(genesisText) | ||
let networkName = genesis.chain_id | ||
|
||
module.exports = { | ||
path: networkPath, | ||
name: networkName | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,16 @@ | ||
const { COSMOS_HOME, NODE_ENV } = process.env | ||
|
||
if (COSMOS_HOME) { | ||
module.exports = COSMOS_HOME | ||
} else { | ||
const home = require('user-home') | ||
const { join } = require('path') | ||
const networkName = require('./network.js').name | ||
|
||
const pkg = require('../package.json') | ||
const DEV = NODE_ENV === 'development' | ||
module.exports = join(home, `.${pkg.name}${DEV ? '-dev' : ''}`) | ||
const appName = pkg.name.toLowerCase() | ||
const appDirName = `.${appName}${DEV ? '-dev' : ''}` | ||
|
||
module.exports = join(home, appDirName, networkName) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
const { join } = require('path') | ||
const { homedir } = require('os') | ||
|
||
describe('Root UI Directory', () => { | ||
Object.assign(process.env, { | ||
NODE_ENV: 'development', | ||
COSMOS_NETWORK: 'app/networks/gaia-2', | ||
COSMOS_HOME: '' | ||
}) | ||
|
||
it('should create the correct path', () => { | ||
let root = require('../../../app/src/root.js') | ||
expect(root).toBe(join(homedir(), '.cosmos-dev/gaia-2')) | ||
}) | ||
}) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why don't we need to backup anymore?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We were previously backing up data when we switched networks, since we had to re-init and we didn't want to just delete the old data. Now we use separate folders for different networks, so we shouldn't ever have to do this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
makes sense!