Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
a3bd2c23
提交
a3bd2c23
authored
8月 08, 2017
作者:
Kevin Atkinson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add "--raw-leaves" option to "ipfs files"
License: MIT Signed-off-by:
Kevin Atkinson
<
k@kevina.org
>
上级
7302c3ab
显示空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
211 行增加
和
187 行删除
+211
-187
files.go
core/commands/files/files.go
+3
-0
file.go
mfs/file.go
+3
-0
t0250-files-api.sh
test/sharness/t0250-files-api.sh
+205
-187
没有找到文件。
core/commands/files/files.go
浏览文件 @
a3bd2c23
...
...
@@ -43,6 +43,7 @@ operations.
},
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)"
),
},
Subcommands
:
map
[
string
]
*
cmds
.
Command
{
"read"
:
FilesReadCmd
,
...
...
@@ -598,6 +599,7 @@ stat' on the file or any of its ancestors.
create
,
_
,
_
:=
req
.
Option
(
"create"
)
.
Bool
()
trunc
,
_
,
_
:=
req
.
Option
(
"truncate"
)
.
Bool
()
flush
,
_
,
_
:=
req
.
Option
(
"flush"
)
.
Bool
()
rawLeaves
,
_
,
_
:=
req
.
Option
(
"raw-leaves"
)
.
Bool
()
nd
,
err
:=
req
.
InvocContext
()
.
GetNode
()
if
err
!=
nil
{
...
...
@@ -620,6 +622,7 @@ stat' on the file or any of its ancestors.
res
.
SetError
(
err
,
cmds
.
ErrNormal
)
return
}
fi
.
RawLeaves
=
rawLeaves
wfd
,
err
:=
fi
.
Open
(
mfs
.
OpenWriteOnly
,
flush
)
if
err
!=
nil
{
...
...
mfs/file.go
浏览文件 @
a3bd2c23
...
...
@@ -23,6 +23,8 @@ type File struct {
dserv
dag
.
DAGService
node
node
.
Node
nodelk
sync
.
Mutex
RawLeaves
bool
}
// NewFile returns a NewFile object with the given parameters
...
...
@@ -79,6 +81,7 @@ func (fi *File) Open(flags int, sync bool) (FileDescriptor, error) {
if
err
!=
nil
{
return
nil
,
err
}
dmod
.
RawLeaves
=
fi
.
RawLeaves
return
&
fileDescriptor
{
inode
:
fi
,
...
...
test/sharness/t0250-files-api.sh
浏览文件 @
a3bd2c23
...
...
@@ -89,114 +89,116 @@ test_sharding() {
}
test_files_api
()
{
ROOT_HASH
=
$1
local
EXTRA ARGS
EXTRA
=
$1
ARGS
=
$2
test_expect_success
"can mkdir in root"
'
ipfs files mkdir /cats
test_expect_success
"can mkdir in root
$EXTRA
"
'
ipfs files
$ARGS
mkdir /cats
'
test_expect_success
"'files ls' lists root by default"
'
ipfs files ls >actual &&
test_expect_success
"'files ls' lists root by default
$EXTRA
"
'
ipfs files
$ARGS
ls >actual &&
echo "cats" >expected &&
test_cmp expected actual
'
test_expect_success
"directory was created"
'
test_expect_success
"directory was created
$EXTRA
"
'
verify_path_exists /cats
'
test_expect_success
"directory is empty"
'
test_expect_success
"directory is empty
$EXTRA
"
'
verify_dir_contents /cats
'
# we do verification of stat formatting now as we depend on it
test_expect_success
"stat works"
'
ipfs files stat / >stat
test_expect_success
"stat works
$EXTRA
"
'
ipfs files
$ARGS
stat / >stat
'
test_expect_success
"hash is first line of stat"
'
test_expect_success
"hash is first line of stat
$EXTRA
"
'
ipfs ls $(head -1 stat) | grep "cats"
'
test_expect_success
"stat --hash gives only hash"
'
ipfs files stat --hash / >actual &&
test_expect_success
"stat --hash gives only hash
$EXTRA
"
'
ipfs files
$ARGS
stat --hash / >actual &&
head -n1 stat >expected &&
test_cmp expected actual
'
test_expect_success
"stat with multiple format options should fail"
'
test_must_fail ipfs files stat --hash --size /
test_expect_success
"stat with multiple format options should fail
$EXTRA
"
'
test_must_fail ipfs files
$ARGS
stat --hash --size /
'
test_expect_success
"compare hash option with format"
'
ipfs files stat --hash / >expected &&
ipfs files stat --format='
"'"
'<hash>'
"'"
' / >actual &&
test_expect_success
"compare hash option with format
$EXTRA
"
'
ipfs files
$ARGS
stat --hash / >expected &&
ipfs files
$ARGS
stat --format='
"'"
'<hash>'
"'"
' / >actual &&
test_cmp expected actual
'
test_expect_success
"compare size option with format"
'
ipfs files stat --size / >expected &&
ipfs files stat --format='
"'"
'<cumulsize>'
"'"
' / >actual &&
test_expect_success
"compare size option with format
$EXTRA
"
'
ipfs files
$ARGS
stat --size / >expected &&
ipfs files
$ARGS
stat --format='
"'"
'<cumulsize>'
"'"
' / >actual &&
test_cmp expected actual
'
test_expect_success
"check root hash"
'
ipfs files stat --hash / > roothash
test_expect_success
"check root hash
$EXTRA
"
'
ipfs files
$ARGS
stat --hash / > roothash
'
test_expect_success
"cannot mkdir /"
'
test_expect_code 1 ipfs files mkdir /
test_expect_success
"cannot mkdir /
$EXTRA
"
'
test_expect_code 1 ipfs files
$ARGS
mkdir /
'
test_expect_success
"check root hash was not changed"
'
ipfs files stat --hash / > roothashafter &&
test_expect_success
"check root hash was not changed
$EXTRA
"
'
ipfs files
$ARGS
stat --hash / > roothashafter &&
test_cmp roothash roothashafter
'
test_expect_success
"can put files into directory"
'
ipfs files cp /ipfs/$FILE1 /cats/file1
test_expect_success
"can put files into directory
$EXTRA
"
'
ipfs files
$ARGS
cp /ipfs/$FILE1 /cats/file1
'
test_expect_success
"file shows up in directory"
'
test_expect_success
"file shows up in directory
$EXTRA
"
'
verify_dir_contents /cats file1
'
test_expect_success
"file has correct hash and size in directory"
'
test_expect_success
"file has correct hash and size in directory
$EXTRA
"
'
echo "file1 $FILE1 4" > ls_l_expected &&
ipfs files ls -l /cats > ls_l_actual &&
ipfs files
$ARGS
ls -l /cats > ls_l_actual &&
test_cmp ls_l_expected ls_l_actual
'
test_expect_success
"can read file"
'
ipfs files read /cats/file1 > file1out
test_expect_success
"can read file
$EXTRA
"
'
ipfs files
$ARGS
read /cats/file1 > file1out
'
test_expect_success
"output looks good"
'
test_expect_success
"output looks good
$EXTRA
"
'
echo foo > expected &&
test_cmp expected file1out
'
test_expect_success
"can put another file into root"
'
ipfs files cp /ipfs/$FILE2 /file2
test_expect_success
"can put another file into root
$EXTRA
"
'
ipfs files
$ARGS
cp /ipfs/$FILE2 /file2
'
test_expect_success
"file shows up in root"
'
test_expect_success
"file shows up in root
$EXTRA
"
'
verify_dir_contents / file2 cats
'
test_expect_success
"can read file"
'
ipfs files read /file2 > file2out
test_expect_success
"can read file
$EXTRA
"
'
ipfs files
$ARGS
read /file2 > file2out
'
test_expect_success
"output looks good"
'
test_expect_success
"output looks good
$EXTRA
"
'
echo bar > expected &&
test_cmp expected file2out
'
test_expect_success
"can make deep directory"
'
ipfs files mkdir -p /cats/this/is/a/dir
test_expect_success
"can make deep directory
$EXTRA
"
'
ipfs files
$ARGS
mkdir -p /cats/this/is/a/dir
'
test_expect_success
"directory was created correctly"
'
test_expect_success
"directory was created correctly
$EXTRA
"
'
verify_path_exists /cats/this/is/a/dir &&
verify_dir_contents /cats this file1 &&
verify_dir_contents /cats/this is &&
...
...
@@ -205,362 +207,378 @@ test_files_api() {
verify_dir_contents /cats/this/is/a/dir
'
test_expect_success
"can copy file into new dir"
'
ipfs files cp /ipfs/$FILE3 /cats/this/is/a/dir/file3
test_expect_success
"can copy file into new dir
$EXTRA
"
'
ipfs files
$ARGS
cp /ipfs/$FILE3 /cats/this/is/a/dir/file3
'
test_expect_success
"can read file"
'
ipfs files read /cats/this/is/a/dir/file3 > output
test_expect_success
"can read file
$EXTRA
"
'
ipfs files
$ARGS
read /cats/this/is/a/dir/file3 > output
'
test_expect_success
"output looks good"
'
test_expect_success
"output looks good
$EXTRA
"
'
echo baz > expected &&
test_cmp expected output
'
test_expect_success
"file shows up in dir"
'
test_expect_success
"file shows up in dir
$EXTRA
"
'
verify_dir_contents /cats/this/is/a/dir file3
'
test_expect_success
"can remove file"
'
ipfs files rm /cats/this/is/a/dir/file3
test_expect_success
"can remove file
$EXTRA
"
'
ipfs files
$ARGS
rm /cats/this/is/a/dir/file3
'
test_expect_success
"file no longer appears"
'
test_expect_success
"file no longer appears
$EXTRA
"
'
verify_dir_contents /cats/this/is/a/dir
'
test_expect_success
"can remove dir"
'
ipfs files rm -r /cats/this/is/a/dir
test_expect_success
"can remove dir
$EXTRA
"
'
ipfs files
$ARGS
rm -r /cats/this/is/a/dir
'
test_expect_success
"dir no longer appears"
'
test_expect_success
"dir no longer appears
$EXTRA
"
'
verify_dir_contents /cats/this/is/a
'
test_expect_success
"can remove file from root"
'
ipfs files rm /file2
test_expect_success
"can remove file from root
$EXTRA
"
'
ipfs files
$ARGS
rm /file2
'
test_expect_success
"file no longer appears"
'
test_expect_success
"file no longer appears
$EXTRA
"
'
verify_dir_contents / cats
'
test_expect_success
"check root hash"
'
ipfs files stat --hash / > roothash
test_expect_success
"check root hash
$EXTRA
"
'
ipfs files
$ARGS
stat --hash / > roothash
'
test_expect_success
"cannot remove root"
'
test_expect_code 1 ipfs files rm -r /
test_expect_success
"cannot remove root
$EXTRA
"
'
test_expect_code 1 ipfs files
$ARGS
rm -r /
'
test_expect_success
"check root hash was not changed"
'
ipfs files stat --hash / > roothashafter &&
test_expect_success
"check root hash was not changed
$EXTRA
"
'
ipfs files
$ARGS
stat --hash / > roothashafter &&
test_cmp roothash roothashafter
'
# test read options
test_expect_success
"read from offset works"
'
ipfs files read -o 1 /cats/file1 > output
test_expect_success
"read from offset works
$EXTRA
"
'
ipfs files
$ARGS
read -o 1 /cats/file1 > output
'
test_expect_success
"output looks good"
'
test_expect_success
"output looks good
$EXTRA
"
'
echo oo > expected &&
test_cmp expected output
'
test_expect_success
"read with size works"
'
ipfs files read -n 2 /cats/file1 > output
test_expect_success
"read with size works
$EXTRA
"
'
ipfs files
$ARGS
read -n 2 /cats/file1 > output
'
test_expect_success
"output looks good"
'
test_expect_success
"output looks good
$EXTRA
"
'
printf fo > expected &&
test_cmp expected output
'
test_expect_success
"cannot read from negative offset"
'
test_expect_code 1 ipfs files read --offset -3 /cats/file1
test_expect_success
"cannot read from negative offset
$EXTRA
"
'
test_expect_code 1 ipfs files
$ARGS
read --offset -3 /cats/file1
'
test_expect_success
"read from offset 0 works"
'
ipfs files read --offset 0 /cats/file1 > output
test_expect_success
"read from offset 0 works
$EXTRA
"
'
ipfs files
$ARGS
read --offset 0 /cats/file1 > output
'
test_expect_success
"output looks good"
'
test_expect_success
"output looks good
$EXTRA
"
'
echo foo > expected &&
test_cmp expected output
'
test_expect_success
"read last byte works"
'
ipfs files read --offset 2 /cats/file1 > output
test_expect_success
"read last byte works
$EXTRA
"
'
ipfs files
$ARGS
read --offset 2 /cats/file1 > output
'
test_expect_success
"output looks good"
'
test_expect_success
"output looks good
$EXTRA
"
'
echo o > expected &&
test_cmp expected output
'
test_expect_success
"offset past end of file fails"
'
test_expect_code 1 ipfs files read --offset 5 /cats/file1
test_expect_success
"offset past end of file fails
$EXTRA
"
'
test_expect_code 1 ipfs files
$ARGS
read --offset 5 /cats/file1
'
test_expect_success
"cannot read negative count bytes"
'
test_expect_success
"cannot read negative count bytes
$EXTRA
"
'
test_expect_code 1 ipfs read --count -1 /cats/file1
'
test_expect_success
"reading zero bytes prints nothing"
'
ipfs files read --count 0 /cats/file1 > output
test_expect_success
"reading zero bytes prints nothing
$EXTRA
"
'
ipfs files
$ARGS
read --count 0 /cats/file1 > output
'
test_expect_success
"output looks good"
'
test_expect_success
"output looks good
$EXTRA
"
'
printf "" > expected &&
test_cmp expected output
'
test_expect_success
"count > len(file) prints entire file"
'
ipfs files read --count 200 /cats/file1 > output
test_expect_success
"count > len(file) prints entire file
$EXTRA
"
'
ipfs files
$ARGS
read --count 200 /cats/file1 > output
'
test_expect_success
"output looks good"
'
test_expect_success
"output looks good
$EXTRA
"
'
echo foo > expected &&
test_cmp expected output
'
# test write
test_expect_success
"can write file"
'
test_expect_success
"can write file
$EXTRA
"
'
echo "ipfs rocks" > tmpfile &&
cat tmpfile | ipfs files write --create /cats/ipfs
cat tmpfile | ipfs files
$ARGS
write --create /cats/ipfs
'
test_expect_success
"file was created"
'
test_expect_success
"file was created
$EXTRA
"
'
verify_dir_contents /cats ipfs file1 this
'
test_expect_success
"can read file we just wrote"
'
ipfs files read /cats/ipfs > output
test_expect_success
"can read file we just wrote
$EXTRA
"
'
ipfs files
$ARGS
read /cats/ipfs > output
'
test_expect_success
"can write to offset"
'
echo "is super cool" | ipfs files write -o 5 /cats/ipfs
test_expect_success
"can write to offset
$EXTRA
"
'
echo "is super cool" | ipfs files
$ARGS
write -o 5 /cats/ipfs
'
test_expect_success
"file looks correct"
'
test_expect_success
"file looks correct
$EXTRA
"
'
echo "ipfs is super cool" > expected &&
ipfs files read /cats/ipfs > output &&
ipfs files
$ARGS
read /cats/ipfs > output &&
test_cmp expected output
'
test_expect_success
"cant write to negative offset"
'
ipfs files stat --hash /cats/ipfs > filehash &&
test_expect_code 1 ipfs files write --offset -1 /cats/ipfs < output
test_expect_success
"file hash correct
$EXTRA
"
'
echo $FILE_HASH > filehash_expected &&
ipfs files $ARGS stat --hash /cats/ipfs > filehash &&
test_cmp filehash_expected filehash
'
test_expect_success
"verify file was not changed"
'
ipfs files stat --hash /cats/ipfs > afterhash &&
test_expect_success
"cant write to negative offset
$EXTRA
"
'
test_expect_code 1 ipfs files $ARGS write --offset -1 /cats/ipfs < output
'
test_expect_success
"verify file was not changed
$EXTRA
"
'
ipfs files $ARGS stat --hash /cats/ipfs > afterhash &&
test_cmp filehash afterhash
'
test_expect_success
"write new file for testing"
'
echo foobar | ipfs files write --create /fun
test_expect_success
"write new file for testing
$EXTRA
"
'
echo foobar | ipfs files
$ARGS
write --create /fun
'
test_expect_success
"write to offset past end works"
'
echo blah | ipfs files write --offset 50 /fun
test_expect_success
"write to offset past end works
$EXTRA
"
'
echo blah | ipfs files
$ARGS
write --offset 50 /fun
'
test_expect_success
"can read file"
'
ipfs files read /fun > sparse_output
test_expect_success
"can read file
$EXTRA
"
'
ipfs files
$ARGS
read /fun > sparse_output
'
test_expect_success
"output looks good"
'
test_expect_success
"output looks good
$EXTRA
"
'
echo foobar > sparse_expected &&
echo blah | dd of=sparse_expected bs=50 seek=1 &&
test_cmp sparse_expected sparse_output
'
test_expect_success
"cleanup"
'
ipfs files rm /fun
test_expect_success
"cleanup
$EXTRA
"
'
ipfs files
$ARGS
rm /fun
'
test_expect_success
"cannot write to directory"
'
ipfs files stat --hash /cats > dirhash &&
test_expect_code 1 ipfs files write /cats < output
test_expect_success
"cannot write to directory
$EXTRA
"
'
ipfs files
$ARGS
stat --hash /cats > dirhash &&
test_expect_code 1 ipfs files
$ARGS
write /cats < output
'
test_expect_success
"verify dir was not changed"
'
ipfs files stat --hash /cats > afterdirhash &&
test_expect_success
"verify dir was not changed
$EXTRA
"
'
ipfs files
$ARGS
stat --hash /cats > afterdirhash &&
test_cmp dirhash afterdirhash
'
test_expect_success
"cannot write to nonexistant path"
'
test_expect_code 1 ipfs files write /cats/bar/ < output
test_expect_success
"cannot write to nonexistant path
$EXTRA
"
'
test_expect_code 1 ipfs files
$ARGS
write /cats/bar/ < output
'
test_expect_success
"no new paths were created"
'
test_expect_success
"no new paths were created
$EXTRA
"
'
verify_dir_contents /cats file1 ipfs this
'
test_expect_success
"write 'no-flush' succeeds"
'
echo "testing" | ipfs files write -f=false -e /cats/walrus
test_expect_success
"write 'no-flush' succeeds
$EXTRA
"
'
echo "testing" | ipfs files
$ARGS
write -f=false -e /cats/walrus
'
test_expect_success
"root hash not bubbled up yet"
'
test_expect_success
"root hash not bubbled up yet
$EXTRA
"
'
test -z "$ONLINE" ||
(ipfs refs local > refsout &&
test_expect_code 1 grep $ROOT_HASH refsout)
'
test_expect_success
"changes bubbled up to root on inspection"
'
ipfs files stat --hash / > root_hash
test_expect_success
"changes bubbled up to root on inspection
$EXTRA
"
'
ipfs files
$ARGS
stat --hash / > root_hash
'
test_expect_success
"root hash looks good"
'
test_expect_success
"root hash looks good
$EXTRA
"
'
export EXP_ROOT_HASH="$ROOT_HASH" &&
echo $EXP_ROOT_HASH > root_hash_exp &&
test_cmp root_hash_exp root_hash
'
test_expect_success
"flush root succeeds"
'
ipfs files flush /
test_expect_success
"flush root succeeds
$EXTRA
"
'
ipfs files
$ARGS
flush /
'
# test mv
test_expect_success
"can mv dir"
'
ipfs files mv /cats/this/is /cats/
test_expect_success
"can mv dir
$EXTRA
"
'
ipfs files
$ARGS
mv /cats/this/is /cats/
'
test_expect_success
"mv worked"
'
test_expect_success
"mv worked
$EXTRA
"
'
verify_dir_contents /cats file1 ipfs this is walrus &&
verify_dir_contents /cats/this
'
test_expect_success
"cleanup, remove 'cats'"
'
ipfs files rm -r /cats
test_expect_success
"cleanup, remove 'cats'
$EXTRA
"
'
ipfs files
$ARGS
rm -r /cats
'
test_expect_success
"cleanup looks good"
'
test_expect_success
"cleanup looks good
$EXTRA
"
'
verify_dir_contents /
'
# test truncating
test_expect_success
"create a new file"
'
echo "some content" | ipfs files write --create /cats
test_expect_success
"create a new file
$EXTRA
"
'
echo "some content" | ipfs files
$ARGS
write --create /cats
'
test_expect_success
"truncate and write over that file"
'
echo "fish" | ipfs files write --truncate /cats
test_expect_success
"truncate and write over that file
$EXTRA
"
'
echo "fish" | ipfs files
$ARGS
write --truncate /cats
'
test_expect_success
"output looks good"
'
ipfs files read /cats > file_out &&
test_expect_success
"output looks good
$EXTRA
"
'
ipfs files
$ARGS
read /cats > file_out &&
echo "fish" > file_exp &&
test_cmp file_out file_exp
'
test_expect_success
"cleanup"
'
ipfs files rm /cats
test_expect_success
"cleanup
$EXTRA
"
'
ipfs files
$ARGS
rm /cats
'
# test flush flags
test_expect_success
"mkdir --flush works"
'
ipfs files mkdir --flush --parents /flushed/deep
test_expect_success
"mkdir --flush works
$EXTRA
"
'
ipfs files
$ARGS
mkdir --flush --parents /flushed/deep
'
test_expect_success
"mkdir --flush works a second time"
'
ipfs files mkdir --flush --parents /flushed/deep
test_expect_success
"mkdir --flush works a second time
$EXTRA
"
'
ipfs files
$ARGS
mkdir --flush --parents /flushed/deep
'
test_expect_success
"dir looks right"
'
test_expect_success
"dir looks right
$EXTRA
"
'
verify_dir_contents / flushed
'
test_expect_success
"child dir looks right"
'
test_expect_success
"child dir looks right
$EXTRA
"
'
verify_dir_contents /flushed deep
'
test_expect_success
"cleanup"
'
ipfs files rm -r /flushed
test_expect_success
"cleanup
$EXTRA
"
'
ipfs files
$ARGS
rm -r /flushed
'
test_expect_success
"child dir looks right"
'
test_expect_success
"child dir looks right
$EXTRA
"
'
verify_dir_contents /
'
# test for https://github.com/ipfs/go-ipfs/issues/2654
test_expect_success
"create and remove dir"
'
ipfs files mkdir /test_dir &&
ipfs files rm -r "/test_dir"
test_expect_success
"create and remove dir
$EXTRA
"
'
ipfs files
$ARGS
mkdir /test_dir &&
ipfs files
$ARGS
rm -r "/test_dir"
'
test_expect_success
"create test file"
'
echo "content" | ipfs files write -e "/test_file"
test_expect_success
"create test file
$EXTRA
"
'
echo "content" | ipfs files
$ARGS
write -e "/test_file"
'
test_expect_success
"copy test file onto test dir"
'
ipfs files cp "/test_file" "/test_dir"
test_expect_success
"copy test file onto test dir
$EXTRA
"
'
ipfs files
$ARGS
cp "/test_file" "/test_dir"
'
test_expect_success
"test /test_dir"
'
ipfs files stat "/test_dir" | grep -q "^Type: file"
test_expect_success
"test /test_dir
$EXTRA
"
'
ipfs files
$ARGS
stat "/test_dir" | grep -q "^Type: file"
'
test_expect_success
"clean up /test_dir and /test_file"
'
ipfs files rm -r /test_dir &&
ipfs files rm -r /test_file
test_expect_success
"clean up /test_dir and /test_file
$EXTRA
"
'
ipfs files
$ARGS
rm -r /test_dir &&
ipfs files
$ARGS
rm -r /test_file
'
test_expect_success
"make a directory and a file"
'
ipfs files mkdir /adir &&
echo "blah" | ipfs files write --create /foobar
test_expect_success
"make a directory and a file
$EXTRA
"
'
ipfs files
$ARGS
mkdir /adir &&
echo "blah" | ipfs files
$ARGS
write --create /foobar
'
test_expect_success
"copy a file into a directory"
'
ipfs files cp /foobar /adir/
test_expect_success
"copy a file into a directory
$EXTRA
"
'
ipfs files
$ARGS
cp /foobar /adir/
'
test_expect_success
"file made it into directory"
'
ipfs files ls /adir | grep foobar
test_expect_success
"file made it into directory
$EXTRA
"
'
ipfs files
$ARGS
ls /adir | grep foobar
'
test_expect_success
"clean up"
'
ipfs files rm -r /foobar &&
ipfs files rm -r /adir
test_expect_success
"clean up
$EXTRA
"
'
ipfs files
$ARGS
rm -r /foobar &&
ipfs files
$ARGS
rm -r /adir
'
test_expect_success
"root mfs entry is empty"
'
test_expect_success
"root mfs entry is empty
$EXTRA
"
'
verify_dir_contents /
'
test_expect_success
"repo gc"
'
test_expect_success
"repo gc
$EXTRA
"
'
ipfs repo gc
'
}
# test offline and online
test_expect_success
"can create some files for testing"
'
tests_for_files_api
()
{
local
EXTRA
EXTRA
=
$1
test_expect_success
"can create some files for testing (
$extra
)"
'
create_files
'
test_files_api QmcwKfTMCT7AaeiD92hWjnZn9b6eh9NxnhfSzN5x2vnDpt
'
ROOT_HASH
=
QmcwKfTMCT7AaeiD92hWjnZn9b6eh9NxnhfSzN5x2vnDpt
FILE_HASH
=
QmQdQt9qooenjeaNhiKHF3hBvmNteB4MQBtgu3jxgf9c7i
test_files_api
"(
$EXTRA
)"
test_expect_success
"can create some files for testing with raw-leaves
"
'
test_expect_success
"can create some files for testing with raw-leaves (
$extra
)
"
'
create_files --raw-leaves
'
test_files_api QmTpKiKcAj4sbeesN6vrs5w3QeVmd4QmGpxRL81hHut4dZ
'
ROOT_HASH
=
QmTpKiKcAj4sbeesN6vrs5w3QeVmd4QmGpxRL81hHut4dZ
test_files_api
"(
$EXTRA
, partial raw-leaves)"
test_expect_success
"can create some files for testing with raw-leaves (
$extra
)"
'
create_files --raw-leaves
'
ROOT_HASH
=
QmW3dMSU6VNd1mEdpk9S3ZYRuR1YwwoXjGaZhkyK6ru9YU
FILE_HASH
=
QmRCgHeoKxCqK2Es6M6nPUDVWz19yNQPnsXGsXeuTkSKpN
test_files_api
"(
$EXTRA
, raw-leaves)"
--raw-leaves
}
tests_for_files_api
"online"
test_launch_ipfs_daemon
--offline
ONLINE
=
1
# set online flag so tests can easily tell
test_expect_success
"can create some files for testing"
'
create_files
'
test_files_api QmcwKfTMCT7AaeiD92hWjnZn9b6eh9NxnhfSzN5x2vnDpt
test_expect_success
"can create some files for testing with raw-leaves"
'
create_files --raw-leaves
'
test_files_api QmTpKiKcAj4sbeesN6vrs5w3QeVmd4QmGpxRL81hHut4dZ
tests_for_files_api
"offline"
test_kill_ipfs_daemon
--offline
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论