Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-unixfs
Commits
76b9a99e
Commit
76b9a99e
authored
Sep 11, 2014
by
Juan Batiz-Benet
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #49 from mappum/feat/init-fix
Init Fix
parents
677d790f
fbec9798
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
5 deletions
+15
-5
cmd/ipfs/init.go
cmd/ipfs/init.go
+6
-2
config/config.go
config/config.go
+4
-3
config/serialize.go
config/serialize.go
+5
-0
No files found.
cmd/ipfs/init.go
View file @
76b9a99e
...
...
@@ -32,9 +32,13 @@ func init() {
}
func
initCmd
(
c
*
commander
.
Command
,
inp
[]
string
)
error
{
_
,
err
:=
os
.
Lstat
(
config
.
DefaultConfigFilePath
)
filename
,
err
:=
config
.
Filename
(
config
.
DefaultConfigFilePath
)
if
err
!=
nil
{
return
errors
.
New
(
"Couldn't get home directory path"
)
}
fi
,
err
:=
os
.
Lstat
(
filename
)
force
:=
c
.
Flag
.
Lookup
(
"f"
)
.
Value
.
Get
()
.
(
bool
)
if
err
!=
nil
&&
!
force
{
if
fi
!=
nil
||
(
err
!=
nil
&&
!
os
.
IsNotExist
(
err
))
&&
!
force
{
return
errors
.
New
(
"ipfs configuration file already exists!
\n
Reinitializing would overwrite your keys.
\n
(use -f to force overwrite)"
)
}
cfg
:=
new
(
config
.
Config
)
...
...
config/config.go
View file @
76b9a99e
...
...
@@ -34,12 +34,13 @@ type Config struct {
Peers
[]
*
SavedPeer
}
var
DefaultConfigFilePath
=
"~/.go-ipfs/config"
var
DefaultConfigFile
=
`{
const
DefaultPathRoot
=
"~/.go-ipfs"
const
DefaultConfigFilePath
=
DefaultPathRoot
+
"/config"
const
DefaultConfigFile
=
`{
"identity": {},
"datastore": {
"type": "leveldb",
"path": "
~/.go-ipfs
/datastore"
"path": "
`
+
DefaultPathRoot
+
`
/datastore"
}
}
`
...
...
config/serialize.go
View file @
76b9a99e
...
...
@@ -22,6 +22,11 @@ func ReadConfigFile(filename string, cfg interface{}) error {
// WriteConfigFile writes the config from `cfg` into `filename`.
func
WriteConfigFile
(
filename
string
,
cfg
interface
{})
error
{
err
:=
os
.
MkdirAll
(
filepath
.
Dir
(
filename
),
0775
)
if
err
!=
nil
{
return
err
}
f
,
err
:=
os
.
Create
(
filename
)
if
err
!=
nil
{
return
err
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment