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-dms3
Commits
62fd9166
Commit
62fd9166
authored
Nov 04, 2014
by
Brian Tiger Chow
Committed by
Juan Batiz-Benet
Nov 14, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(ipfs2/init) datastore
parent
542c2a2d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
20 deletions
+30
-20
cmd/ipfs2/init.go
cmd/ipfs2/init.go
+30
-20
No files found.
cmd/ipfs2/init.go
View file @
62fd9166
...
...
@@ -86,28 +86,11 @@ func doInit(configRoot string, dspath string, force bool, nBitsForKeypair int) e
}
cfg
:=
new
(
config
.
Config
)
if
len
(
dspath
)
==
0
{
dspath
,
err
=
config
.
DataStorePath
(
""
)
if
err
!=
nil
{
return
err
}
}
cfg
.
Datastore
=
config
.
Datastore
{
Path
:
dspath
,
Type
:
"leveldb"
,
}
// Construct the data store if missing
if
err
:=
os
.
MkdirAll
(
dspath
,
os
.
ModePerm
);
err
!=
nil
{
ds
,
err
:=
datastoreConfig
(
dspath
)
if
err
!=
nil
{
return
err
}
// Check the directory is writeable
if
f
,
err
:=
os
.
Create
(
filepath
.
Join
(
dspath
,
"._check_writeable"
));
err
==
nil
{
os
.
Remove
(
f
.
Name
())
}
else
{
return
errors
.
New
(
"Datastore '"
+
dspath
+
"' is not writeable"
)
}
cfg
.
Datastore
=
ds
cfg
.
Identity
=
config
.
Identity
{}
...
...
@@ -162,3 +145,30 @@ func doInit(configRoot string, dspath string, force bool, nBitsForKeypair int) e
}
return
nil
}
func
datastoreConfig
(
dspath
string
)
(
config
.
Datastore
,
error
)
{
ds
:=
config
.
Datastore
{}
if
len
(
dspath
)
==
0
{
var
err
error
dspath
,
err
=
config
.
DataStorePath
(
""
)
if
err
!=
nil
{
return
ds
,
err
}
}
ds
.
Path
=
dspath
ds
.
Type
=
"leveldb"
// Construct the data store if missing
if
err
:=
os
.
MkdirAll
(
dspath
,
os
.
ModePerm
);
err
!=
nil
{
return
ds
,
err
}
// Check the directory is writeable
if
f
,
err
:=
os
.
Create
(
filepath
.
Join
(
dspath
,
"._check_writeable"
));
err
==
nil
{
os
.
Remove
(
f
.
Name
())
}
else
{
return
ds
,
errors
.
New
(
"Datastore '"
+
dspath
+
"' is not writeable"
)
}
return
ds
,
nil
}
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