Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
798afedf
提交
798afedf
authored
10月 19, 2017
作者:
Kevin Atkinson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Make --hash and related option local to sub-commands that use them.
License: MIT Signed-off-by:
Kevin Atkinson
<
k@kevina.org
>
上级
00a3b1df
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
23 行增加
和
12 行删除
+23
-12
files.go
core/commands/files/files.go
+23
-12
t0250-files-api.sh
test/sharness/t0250-files-api.sh
+0
-0
没有找到文件。
core/commands/files/files.go
浏览文件 @
798afedf
...
...
@@ -41,21 +41,10 @@ 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 'ipfs repo gc' concurrently with '--flush=false'
operations.
The --cid-version and --hash-fun option only apply to newly created files
and directories. If not specified these proprieties are inhertied
from the parent directory.
`
,
},
Options
:
[]
cmds
.
Option
{
cmds
.
BoolOption
(
"f"
,
"flush"
,
"Flush target and ancestors after write."
)
.
Default
(
true
),
cmds
.
BoolOption
(
"raw-leaves"
,
"Use raw blocks for newly created leaf nodes. (experimental)"
),
cmds
.
IntOption
(
"cid-version"
,
"cid-ver"
,
"Cid version. Non-zero value will change default of 'raw-leaves' to true. (experimental)"
),
cmds
.
StringOption
(
"hash-fun"
,
"Hash function to use. Will set Cid version to 1 if used. (experimental)"
),
// ^^fixme: can't use just "hash" as the option name as the
// conflicts with "--hash" usage by the stat command, this is
// unfortunate as it creates an inconsistency with the "add"
// that uses "hash"
},
Subcommands
:
map
[
string
]
*
cmds
.
Command
{
"read"
:
FilesReadCmd
,
...
...
@@ -71,6 +60,9 @@ from the parent directory.
},
}
var
cidVersionOption
=
cmds
.
IntOption
(
"cid-version"
,
"cid-ver"
,
"Cid version to use. (experimental)"
)
var
hashOption
=
cmds
.
StringOption
(
"hash"
,
"Hash function to use. Will set Cid version to 1 if used. (experimental)"
)
var
formatError
=
errors
.
New
(
"Format was set by multiple options. Only one format option is allowed"
)
var
FilesStatCmd
=
&
cmds
.
Command
{
...
...
@@ -576,6 +568,13 @@ a beginning offset to write to. The entire length of the input will be written.
If the '--create' option is specified, the file will be created if it does not
exist. Nonexistant intermediate directories will not be created.
Newly created files will have the same CID version and hash function of the
parent directory unless the --cid-version and --hash options are used.
Newly created leaves will be in the legacy format (Protobuf) if the
CID version is 0, or raw is the CID version is non-zero. Use of the
--raw-leaves option will override this behavior.
If the '--flush' option is set to false, changes will not be propogated to the
merkledag root. This can make operations much faster when doing a large number
of writes to a deeper directory structure.
...
...
@@ -601,6 +600,9 @@ stat' on the file or any of its ancestors.
cmds
.
BoolOption
(
"create"
,
"e"
,
"Create the file if it does not exist."
),
cmds
.
BoolOption
(
"truncate"
,
"t"
,
"Truncate the file to size zero before writing."
),
cmds
.
IntOption
(
"count"
,
"n"
,
"Maximum number of bytes to read."
),
cmds
.
BoolOption
(
"raw-leaves"
,
"Use raw blocks for newly created leaf nodes. (experimental)"
),
cidVersionOption
,
hashOption
,
},
Run
:
func
(
req
cmds
.
Request
,
res
cmds
.
Response
)
{
path
,
err
:=
checkPath
(
req
.
Arguments
()[
0
])
...
...
@@ -709,6 +711,9 @@ var FilesMkdirCmd = &cmds.Command{
ShortDescription
:
`
Create the directory if it does not already exist.
The directory will have the same CID version and hash function of the
parent directory unless the --cid-version and --hash options are used.
NOTE: All paths must be absolute.
Examples:
...
...
@@ -723,6 +728,8 @@ Examples:
},
Options
:
[]
cmds
.
Option
{
cmds
.
BoolOption
(
"parents"
,
"p"
,
"No error if existing, make parent directories as needed."
),
cidVersionOption
,
hashOption
,
},
Run
:
func
(
req
cmds
.
Request
,
res
cmds
.
Response
)
{
n
,
err
:=
req
.
InvocContext
()
.
GetNode
()
...
...
@@ -801,6 +808,10 @@ Change the cid version or hash function of the root node of a given path.
Arguments
:
[]
cmds
.
Argument
{
cmds
.
StringArg
(
"path"
,
false
,
false
,
"Path to change. Default: '/'."
),
},
Options
:
[]
cmds
.
Option
{
cidVersionOption
,
hashOption
,
},
Run
:
func
(
req
cmds
.
Request
,
res
cmds
.
Response
)
{
nd
,
err
:=
req
.
InvocContext
()
.
GetNode
()
if
err
!=
nil
{
...
...
@@ -959,7 +970,7 @@ Remove files or directories.
func
getPrefix
(
req
cmds
.
Request
)
(
*
cid
.
Prefix
,
error
)
{
cidVer
,
cidVerSet
,
_
:=
req
.
Option
(
"cid-version"
)
.
Int
()
hashFunStr
,
hashFunSet
,
_
:=
req
.
Option
(
"hash
-fun
"
)
.
String
()
hashFunStr
,
hashFunSet
,
_
:=
req
.
Option
(
"hash"
)
.
String
()
if
!
cidVerSet
&&
!
hashFunSet
{
return
nil
,
nil
...
...
test/sharness/t0250-files-api.sh
浏览文件 @
798afedf
差异被折叠。
点击展开。
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论