Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
62cd0781
提交
62cd0781
authored
2月 19, 2016
作者:
Richard Littauer
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Copy edited files command file
License: MIT Signed-off-by:
Richard Littauer
<
richard.littauer@gmail.com
>
上级
27cbef15
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
16 行增加
和
16 行删除
+16
-16
files.go
core/commands/files/files.go
+16
-16
没有找到文件。
core/commands/files/files.go
浏览文件 @
62cd0781
...
...
@@ -26,11 +26,11 @@ var FilesCmd = &cmds.Command{
Helptext
:
cmds
.
HelpText
{
Tagline
:
"Manipulate unixfs files."
,
ShortDescription
:
`
Files is an API for manipulating
ipfs
objects as if they were a unix filesystem.
Files is an API for manipulating
IPFS
objects as if they were a unix filesystem.
Note:
Most of the subcommands of 'ipfs files' accept the '--flush' flag. It defaults to
true. Use caution when setting this flag to false
,
It will improve performance
true. Use caution when setting this flag to false
.
It will improve performance
for large numbers of file operations, but it does so at the cost of consistency
guarantees. If the daemon is unexpectedly killed before running 'ipfs files flush'
on the files in question, then data may be lost. This also applies to running
...
...
@@ -38,7 +38,7 @@ on the files in question, then data may be lost. This also applies to running
`
,
},
Options
:
[]
cmds
.
Option
{
cmds
.
BoolOption
(
"f"
,
"flush"
,
"Flush target and ancestors after write
(default: true)
."
),
cmds
.
BoolOption
(
"f"
,
"flush"
,
"Flush target and ancestors after write
. Default: true
."
),
},
Subcommands
:
map
[
string
]
*
cmds
.
Command
{
"read"
:
FilesReadCmd
,
...
...
@@ -131,7 +131,7 @@ func statNode(ds dag.DAGService, fsn mfs.FSNode) (*Object, error) {
case
mfs
.
TFile
:
ndtype
=
"file"
default
:
return
nil
,
fmt
.
Errorf
(
"
u
nrecognized node type: %s"
,
fsn
.
Type
())
return
nil
,
fmt
.
Errorf
(
"
U
nrecognized node type: %s"
,
fsn
.
Type
())
}
return
&
Object
{
...
...
@@ -364,7 +364,7 @@ Examples:
fi
,
ok
:=
fsn
.
(
*
mfs
.
File
)
if
!
ok
{
res
.
SetError
(
fmt
.
Errorf
(
"%s was not a file"
,
path
),
cmds
.
ErrNormal
)
res
.
SetError
(
fmt
.
Errorf
(
"%s was not a file
.
"
,
path
),
cmds
.
ErrNormal
)
return
}
...
...
@@ -382,7 +382,7 @@ Examples:
return
}
if
offset
<
0
{
res
.
SetError
(
fmt
.
Errorf
(
"
cannot specify negative offset
"
),
cmds
.
ErrNormal
)
res
.
SetError
(
fmt
.
Errorf
(
"
Cannot specify negative offset.
"
),
cmds
.
ErrNormal
)
return
}
...
...
@@ -393,7 +393,7 @@ Examples:
}
if
int64
(
offset
)
>
filen
{
res
.
SetError
(
fmt
.
Errorf
(
"
offset was past end of file (%d > %d)
"
,
offset
,
filen
),
cmds
.
ErrNormal
)
res
.
SetError
(
fmt
.
Errorf
(
"
Offset was past end of file (%d > %d).
"
,
offset
,
filen
),
cmds
.
ErrNormal
)
return
}
...
...
@@ -411,7 +411,7 @@ Examples:
}
if
found
{
if
count
<
0
{
res
.
SetError
(
fmt
.
Errorf
(
"
cannot specify negative 'count'
"
),
cmds
.
ErrNormal
)
res
.
SetError
(
fmt
.
Errorf
(
"
Cannot specify negative 'count'.
"
),
cmds
.
ErrNormal
)
return
}
r
=
io
.
LimitReader
(
r
,
int64
(
count
))
...
...
@@ -653,14 +653,14 @@ Examples:
var
FilesFlushCmd
=
&
cmds
.
Command
{
Helptext
:
cmds
.
HelpText
{
Tagline
:
"
flush a given path's data to disk
"
,
Tagline
:
"
Flush a given path's data to disk.
"
,
ShortDescription
:
`
f
lush a given path to disk. This is only useful when other commands
F
lush a given path to disk. This is only useful when other commands
are run with the '--flush=false'.
`
,
},
Arguments
:
[]
cmds
.
Argument
{
cmds
.
StringArg
(
"path"
,
false
,
false
,
"
path to flush (default '/')
"
),
cmds
.
StringArg
(
"path"
,
false
,
false
,
"
Path to flush. Default: '/'.
"
),
},
Run
:
func
(
req
cmds
.
Request
,
res
cmds
.
Response
)
{
nd
,
err
:=
req
.
InvocContext
()
.
GetNode
()
...
...
@@ -686,7 +686,7 @@ var FilesRmCmd = &cmds.Command{
Helptext
:
cmds
.
HelpText
{
Tagline
:
"Remove a file."
,
ShortDescription
:
`
remove files or directories
Remove files or directories.
$ ipfs files rm /foo
$ ipfs files ls /bar
...
...
@@ -735,7 +735,7 @@ remove files or directories
pdir
,
ok
:=
parent
.
(
*
mfs
.
Directory
)
if
!
ok
{
res
.
SetError
(
fmt
.
Errorf
(
"
n
o such file or directory: %s"
,
path
),
cmds
.
ErrNormal
)
res
.
SetError
(
fmt
.
Errorf
(
"
N
o such file or directory: %s"
,
path
),
cmds
.
ErrNormal
)
return
}
...
...
@@ -827,7 +827,7 @@ func getFileHandle(r *mfs.Root, path string, create bool) (*mfs.File, error) {
fi
,
ok
:=
fsn
.
(
*
mfs
.
File
)
if
!
ok
{
return
nil
,
errors
.
New
(
"
expected *mfs.File, didnt get it. This is likely a race condition
"
)
return
nil
,
errors
.
New
(
"
Expected *mfs.File, didnt get it. This is likely a race condition.
"
)
}
return
fi
,
nil
...
...
@@ -838,11 +838,11 @@ func getFileHandle(r *mfs.Root, path string, create bool) (*mfs.File, error) {
func
checkPath
(
p
string
)
(
string
,
error
)
{
if
len
(
p
)
==
0
{
return
""
,
fmt
.
Errorf
(
"
paths must not be empty
"
)
return
""
,
fmt
.
Errorf
(
"
Paths must not be empty.
"
)
}
if
p
[
0
]
!=
'/'
{
return
""
,
fmt
.
Errorf
(
"
paths must start with a leading slash
"
)
return
""
,
fmt
.
Errorf
(
"
Paths must start with a leading slash.
"
)
}
cleaned
:=
gopath
.
Clean
(
p
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论