Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
1dede1b1
Unverified
提交
1dede1b1
authored
7月 19, 2018
作者:
Whyrusleeping
提交者:
GitHub
7月 19, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #5219 from schomatis/fix/mfs/remove-sort
mfs: remove `sort` from `ListNames()`
上级
6f140d25
dfb81abf
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
23 行增加
和
7 行删除
+23
-7
files.go
core/commands/files.go
+10
-1
dir.go
mfs/dir.go
+0
-3
t0250-files-api.sh
test/sharness/t0250-files-api.sh
+13
-3
没有找到文件。
core/commands/files.go
浏览文件 @
1dede1b1
...
...
@@ -8,6 +8,7 @@ import (
"io"
"os"
gopath
"path"
"sort"
"strings"
bservice
"github.com/ipfs/go-ipfs/blockservice"
...
...
@@ -405,6 +406,7 @@ Examples:
},
Options
:
[]
cmdkit
.
Option
{
cmdkit
.
BoolOption
(
"l"
,
"Use long listing format."
),
cmdkit
.
BoolOption
(
"U"
,
"Do not sort; list entries in directory order."
),
},
Run
:
func
(
req
oldcmds
.
Request
,
res
oldcmds
.
Response
)
{
var
arg
string
...
...
@@ -499,8 +501,15 @@ Examples:
}
buf
:=
new
(
bytes
.
Buffer
)
long
,
_
,
_
:=
res
.
Request
()
.
Option
(
"l"
)
.
Bool
()
noSort
,
_
,
_
:=
res
.
Request
()
.
Option
(
"U"
)
.
Bool
()
if
!
noSort
{
sort
.
Slice
(
out
.
Entries
,
func
(
i
,
j
int
)
bool
{
return
strings
.
Compare
(
out
.
Entries
[
i
]
.
Name
,
out
.
Entries
[
j
]
.
Name
)
<
0
})
}
long
,
_
,
_
:=
res
.
Request
()
.
Option
(
"l"
)
.
Bool
()
for
_
,
o
:=
range
out
.
Entries
{
if
long
{
fmt
.
Fprintf
(
buf
,
"%s
\t
%s
\t
%d
\n
"
,
o
.
Name
,
o
.
Hash
,
o
.
Size
)
...
...
mfs/dir.go
浏览文件 @
1dede1b1
...
...
@@ -6,7 +6,6 @@ import (
"fmt"
"os"
"path"
"sort"
"sync"
"time"
...
...
@@ -247,8 +246,6 @@ func (d *Directory) ListNames(ctx context.Context) ([]string, error) {
return
nil
,
err
}
sort
.
Strings
(
out
)
return
out
,
nil
}
...
...
test/sharness/t0250-files-api.sh
浏览文件 @
1dede1b1
...
...
@@ -56,19 +56,29 @@ test_sharding() {
test_expect_success
"can make 100 files in a directory
$EXTRA
"
'
printf "" > list_exp_raw
for i in `seq 100`
for i in `seq 100
-1 1
`
do
echo $i | ipfs files write --create /foo/file$i || return 1
echo file$i >> list_exp_raw
done
'
# Create the files in reverse (unsorted) order (`seq 100 -1 1`)
# to check the sort in the `ipfs files ls` command. `ProtoNode`
# links are always sorted at the DAG layer so the sorting feature
# is tested with sharded directories.
test_expect_success
"listing works
$EXTRA
"
'
ipfs files ls /foo
|sort
> list_out &&
test_expect_success
"
sorted
listing works
$EXTRA
"
'
ipfs files ls /foo > list_out &&
sort list_exp_raw > list_exp &&
test_cmp list_exp list_out
'
test_expect_success
"unsorted listing works
$EXTRA
"
'
ipfs files ls -U /foo > list_out &&
sort list_exp_raw > sort_list_not_exp &&
! test_cmp sort_list_not_exp list_out
'
test_expect_success
"can read a file from sharded directory
$EXTRA
"
'
ipfs files read /foo/file65 > file_out &&
echo "65" > file_exp &&
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论