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
2607bee4
Commit
2607bee4
authored
Sep 17, 2014
by
Jeromy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change config flag to accept config dir instead of file path
parent
9e4b8586
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
54 additions
and
23 deletions
+54
-23
cmd/ipfs/add.go
cmd/ipfs/add.go
+4
-1
cmd/ipfs/cat.go
cmd/ipfs/cat.go
+6
-8
cmd/ipfs/init.go
cmd/ipfs/init.go
+21
-3
cmd/ipfs/ipfs.go
cmd/ipfs/ipfs.go
+11
-8
cmd/ipfs/ls.go
cmd/ipfs/ls.go
+4
-1
cmd/ipfs/mount_unix.go
cmd/ipfs/mount_unix.go
+4
-1
cmd/ipfs/refs.go
cmd/ipfs/refs.go
+4
-1
No files found.
cmd/ipfs/add.go
View file @
2607bee4
...
...
@@ -46,7 +46,10 @@ func addCmd(c *commander.Command, inp []string) error {
err
:=
daemon
.
SendCommand
(
cmd
,
"localhost:12345"
)
if
err
!=
nil
{
// Do locally
conf
:=
getConfig
(
c
.
Parent
)
conf
,
err
:=
getConfigDir
(
c
.
Parent
)
if
err
!=
nil
{
return
err
}
n
,
err
:=
localNode
(
conf
,
false
)
if
err
!=
nil
{
return
err
...
...
cmd/ipfs/cat.go
View file @
2607bee4
...
...
@@ -28,18 +28,16 @@ func catCmd(c *commander.Command, inp []string) error {
return
nil
}
expanded
,
err
:=
u
.
ExpandPathnames
(
inp
)
if
err
!=
nil
{
return
err
}
com
:=
daemon
.
NewCommand
()
com
.
Command
=
"cat"
com
.
Args
=
expanded
com
.
Args
=
inp
err
=
daemon
.
SendCommand
(
com
,
"localhost:12345"
)
err
:
=
daemon
.
SendCommand
(
com
,
"localhost:12345"
)
if
err
!=
nil
{
conf
:=
getConfig
(
c
.
Parent
)
conf
,
err
:=
getConfigDir
(
c
.
Parent
)
if
err
!=
nil
{
return
err
}
n
,
err
:=
localNode
(
conf
,
false
)
if
err
!=
nil
{
return
err
...
...
cmd/ipfs/init.go
View file @
2607bee4
...
...
@@ -32,12 +32,27 @@ func init() {
}
func
initCmd
(
c
*
commander
.
Command
,
inp
[]
string
)
error
{
filename
,
err
:=
config
.
Filename
(
config
.
DefaultConfigFilePath
)
configpath
,
err
:=
getConfigDir
(
c
.
Parent
)
if
err
!=
nil
{
return
err
}
if
configpath
==
""
{
configpath
,
err
=
u
.
TildeExpansion
(
"~/.go-ipfs"
)
if
err
!=
nil
{
return
err
}
}
filename
,
err
:=
config
.
Filename
(
configpath
+
"/config"
)
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
)
force
,
ok
:=
c
.
Flag
.
Lookup
(
"f"
)
.
Value
.
Get
()
.
(
bool
)
if
!
ok
{
return
errors
.
New
(
"failed to parse force flag"
)
}
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)"
)
}
...
...
@@ -55,7 +70,10 @@ func initCmd(c *commander.Command, inp []string) error {
// This needs thought
// cfg.Identity.Address = ""
nbits
:=
c
.
Flag
.
Lookup
(
"b"
)
.
Value
.
Get
()
.
(
int
)
nbits
,
ok
:=
c
.
Flag
.
Lookup
(
"b"
)
.
Value
.
Get
()
.
(
int
)
if
!
ok
{
return
errors
.
New
(
"failed to get bits flag"
)
}
if
nbits
<
1024
{
return
errors
.
New
(
"Bitsize less than 1024 is considered unsafe."
)
}
...
...
cmd/ipfs/ipfs.go
View file @
2607bee4
package
main
import
(
"errors"
"fmt"
"os"
...
...
@@ -52,7 +53,7 @@ Use "ipfs help <command>" for more information about a command.
}
func
init
()
{
CmdIpfs
.
Flag
.
String
(
"c"
,
"~/.go-ipfs/config"
,
"specify config
file
"
)
CmdIpfs
.
Flag
.
String
(
"c"
,
config
.
DefaultPathRoot
,
"specify config
directory
"
)
}
func
ipfsCmd
(
c
*
commander
.
Command
,
args
[]
string
)
error
{
...
...
@@ -72,9 +73,8 @@ func main() {
return
}
func
localNode
(
conf
string
,
online
bool
)
(
*
core
.
IpfsNode
,
error
)
{
//todo implement config file flag
cfg
,
err
:=
config
.
Load
(
conf
)
func
localNode
(
confdir
string
,
online
bool
)
(
*
core
.
IpfsNode
,
error
)
{
cfg
,
err
:=
config
.
Load
(
confdir
+
"/config"
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -84,11 +84,14 @@ func localNode(conf string, online bool) (*core.IpfsNode, error) {
// Gets the config "-c" flag from the command, or returns
// the empty string
func
getConfig
(
c
*
commander
.
Command
)
string
{
func
getConfig
Dir
(
c
*
commander
.
Command
)
(
string
,
error
)
{
conf
:=
c
.
Flag
.
Lookup
(
"c"
)
.
Value
.
Get
()
if
conf
==
nil
{
return
""
,
nil
}
confStr
,
ok
:=
conf
.
(
string
)
if
ok
{
return
confStr
if
!
ok
{
return
""
,
errors
.
New
(
"failed to retrieve config flag value."
)
}
return
""
return
confStr
,
nil
}
cmd/ipfs/ls.go
View file @
2607bee4
...
...
@@ -36,7 +36,10 @@ func lsCmd(c *commander.Command, inp []string) error {
com
.
Args
=
inp
err
:=
daemon
.
SendCommand
(
com
,
"localhost:12345"
)
if
err
!=
nil
{
conf
:=
getConfig
(
c
.
Parent
)
conf
,
err
:=
getConfigDir
(
c
.
Parent
)
if
err
!=
nil
{
return
err
}
n
,
err
:=
localNode
(
conf
,
false
)
if
err
!=
nil
{
return
err
...
...
cmd/ipfs/mount_unix.go
View file @
2607bee4
...
...
@@ -33,7 +33,10 @@ func mountCmd(c *commander.Command, inp []string) error {
return
nil
}
conf
:=
getConfig
(
c
.
Parent
)
conf
,
err
:=
getConfigDir
(
c
.
Parent
)
if
err
!=
nil
{
return
err
}
n
,
err
:=
localNode
(
conf
,
true
)
if
err
!=
nil
{
return
err
...
...
cmd/ipfs/refs.go
View file @
2607bee4
...
...
@@ -46,7 +46,10 @@ func refCmd(c *commander.Command, inp []string) error {
err
:=
daemon
.
SendCommand
(
cmd
,
"localhost:12345"
)
if
err
!=
nil
{
// Do locally
conf
:=
getConfig
(
c
.
Parent
)
conf
,
err
:=
getConfigDir
(
c
.
Parent
)
if
err
!=
nil
{
return
err
}
n
,
err
:=
localNode
(
conf
,
false
)
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