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
e200c089
Commit
e200c089
authored
Sep 25, 2014
by
Shanti Bouchez-Mongardé
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Correct style.
parent
7705dfb9
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
35 additions
and
18 deletions
+35
-18
cmd/ipfs/config.go
cmd/ipfs/config.go
+1
-1
cmd/ipfs/init.go
cmd/ipfs/init.go
+2
-3
cmd/ipfs/ipfs.go
cmd/ipfs/ipfs.go
+4
-4
config/config.go
config/config.go
+28
-10
No files found.
cmd/ipfs/config.go
View file @
e200c089
...
...
@@ -49,7 +49,7 @@ func configCmd(c *commander.Command, inp []string) error {
return
err
}
filename
,
err
:=
config
.
GetConfigFilePath
(
confdir
)
filename
,
err
:=
config
.
Filename
(
confdir
)
if
err
!=
nil
{
return
err
}
...
...
cmd/ipfs/init.go
View file @
e200c089
...
...
@@ -39,7 +39,7 @@ func initCmd(c *commander.Command, inp []string) error {
}
u
.
POut
(
"initializing ipfs node at %s
\n
"
,
configpath
)
filename
,
err
:=
config
.
GetConfigFilePath
(
configpath
)
filename
,
err
:=
config
.
Filename
(
configpath
)
if
err
!=
nil
{
return
errors
.
New
(
"Couldn't get home directory path"
)
}
...
...
@@ -63,11 +63,10 @@ func initCmd(c *commander.Command, inp []string) error {
cfg
.
Datastore
=
config
.
Datastore
{}
if
len
(
dspath
)
==
0
{
dspath
,
err
=
config
.
GetDefaultPathRoot
(
)
dspath
,
err
=
config
.
DataStorePath
(
""
)
if
err
!=
nil
{
return
err
}
dspath
=
dspath
+
"/datastore"
}
cfg
.
Datastore
.
Path
=
dspath
cfg
.
Datastore
.
Type
=
"leveldb"
...
...
cmd/ipfs/ipfs.go
View file @
e200c089
...
...
@@ -53,7 +53,7 @@ Use "ipfs help <command>" for more information about a command.
}
func
init
()
{
config
,
err
:=
config
.
GetDefault
PathRoot
()
config
,
err
:=
config
.
PathRoot
()
if
err
!=
nil
{
config
=
""
}
...
...
@@ -78,7 +78,7 @@ func main() {
}
func
localNode
(
confdir
string
,
online
bool
)
(
*
core
.
IpfsNode
,
error
)
{
filename
,
err
:=
config
.
GetConfigFilePath
(
confdir
)
filename
,
err
:=
config
.
Filename
(
confdir
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -96,14 +96,14 @@ func localNode(confdir string, online bool) (*core.IpfsNode, error) {
func
getConfigDir
(
c
*
commander
.
Command
)
(
string
,
error
)
{
conf
:=
c
.
Flag
.
Lookup
(
"c"
)
.
Value
.
Get
()
if
conf
==
nil
{
return
config
.
GetDefault
PathRoot
()
return
config
.
PathRoot
()
}
confStr
,
ok
:=
conf
.
(
string
)
if
!
ok
{
return
""
,
errors
.
New
(
"failed to retrieve config flag value."
)
}
if
len
(
confStr
)
==
0
{
return
config
.
GetDefault
PathRoot
()
return
config
.
PathRoot
()
}
return
u
.
TildeExpansion
(
confStr
)
...
...
config/config.go
View file @
e200c089
...
...
@@ -6,6 +6,7 @@ import (
"encoding/base64"
"errors"
"os"
"path/filepath"
u
"github.com/jbenet/go-ipfs/util"
)
...
...
@@ -42,27 +43,44 @@ type Config struct {
Bootstrap
[]
*
BootstrapPeer
// local nodes's bootstrap peers
}
// Return the default configuration root directory
func
GetDefaultPathRoot
()
(
string
,
error
)
{
dir
:=
os
.
Getenv
(
"IPFS_CONFIG_DIR"
)
const
DefaultPathRoot
=
"~/.go-ipfs"
const
DefaultConfigFile
=
"config"
const
DefaultDataStoreDirectory
=
"datastore"
const
EnvDir
=
"IPFS_DIR"
// PathRoot returns the default configuration root directory
func
PathRoot
()
(
string
,
error
)
{
dir
:=
os
.
Getenv
(
EnvDir
)
var
err
error
if
len
(
dir
)
==
0
{
dir
,
err
=
u
.
TildeExpansion
(
"~/.go-ipfs"
)
dir
,
err
=
u
.
TildeExpansion
(
DefaultPathRoot
)
}
return
dir
,
err
}
//
R
eturn the
configuration file path given a
configuration root
directory
//
If the configuration root directory is empty, use the default one
func
GetConfigFile
Path
(
configroot
string
)
(
string
,
error
)
{
//
Path r
eturn
s
the
path `extension` relative to the
configuration root
. If an
//
empty string is provided for `configroot`, the default root is used.
func
Path
(
configroot
,
extension
string
)
(
string
,
error
)
{
if
len
(
configroot
)
==
0
{
dir
,
err
:=
GetDefault
PathRoot
()
return
dir
+
"/config"
,
err
dir
,
err
:=
PathRoot
()
return
filepath
.
Join
(
dir
,
extension
)
,
err
}
else
{
return
configroot
+
"/config"
,
nil
return
filepath
.
Join
(
configroot
,
extension
)
,
nil
}
}
// DataStorePath returns the default data store path given a configuration root
// (set an empty string to have the default configuration root)
func
DataStorePath
(
configroot
string
)
(
string
,
error
)
{
return
Path
(
configroot
,
DefaultDataStoreDirectory
);
}
// Filename returns the configuration file path given a configuration root
// directory. If the configuration root directory is empty, use the default one
func
Filename
(
configroot
string
)
(
string
,
error
)
{
return
Path
(
configroot
,
DefaultConfigFile
);
}
// DecodePrivateKey is a helper to decode the users PrivateKey
func
(
i
*
Identity
)
DecodePrivateKey
(
passphrase
string
)
(
crypto
.
PrivateKey
,
error
)
{
pkb
,
err
:=
base64
.
StdEncoding
.
DecodeString
(
i
.
PrivKey
)
...
...
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