Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
2106b4e3
提交
2106b4e3
authored
3月 14, 2019
作者:
Łukasz Magiera
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
coreapi mfs: gofmt
License: MIT Signed-off-by:
Łukasz Magiera
<
magik6k@gmail.com
>
上级
65a7dbaf
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
10 行增加
和
11 行删除
+10
-11
coreapi.go
core/coreapi/coreapi.go
+1
-1
mfs.go
core/coreapi/mfs.go
+9
-10
没有找到文件。
core/coreapi/coreapi.go
浏览文件 @
2106b4e3
...
@@ -72,7 +72,7 @@ type CoreAPI struct {
...
@@ -72,7 +72,7 @@ type CoreAPI struct {
checkPublishAllowed
func
()
error
checkPublishAllowed
func
()
error
checkOnline
func
(
allowOffline
bool
)
error
checkOnline
func
(
allowOffline
bool
)
error
filesRoot
*
mfs
.
Root
// TODO: option filtering
filesRoot
*
mfs
.
Root
// TODO: option filtering
// ONLY for re-applying options in WithOptions, DO NOT USE ANYWHERE ELSE
// ONLY for re-applying options in WithOptions, DO NOT USE ANYWHERE ELSE
nd
*
core
.
IpfsNode
nd
*
core
.
IpfsNode
...
...
core/coreapi/mfs.go
浏览文件 @
2106b4e3
...
@@ -2,15 +2,15 @@ package coreapi
...
@@ -2,15 +2,15 @@ package coreapi
import
(
import
(
"context"
"context"
"errors"
"fmt"
"fmt"
"github.com/ipfs/go-mfs"
"github.com/pkg/errors"
"io"
"io"
"os"
"os"
gopath
"path"
gopath
"path"
"sync"
"sync"
"time"
"time"
"github.com/ipfs/go-mfs"
coreiface
"github.com/ipfs/interface-go-ipfs-core"
coreiface
"github.com/ipfs/interface-go-ipfs-core"
)
)
...
@@ -19,7 +19,7 @@ const defaultDirPerm = 0755
...
@@ -19,7 +19,7 @@ const defaultDirPerm = 0755
type
MfsAPI
CoreAPI
type
MfsAPI
CoreAPI
type
fileNodeInfo
struct
{
type
fileNodeInfo
struct
{
l
mfs
.
NodeListing
l
mfs
.
NodeListing
}
}
...
@@ -48,7 +48,7 @@ func (i *fileNodeInfo) Sys() interface{} {
...
@@ -48,7 +48,7 @@ func (i *fileNodeInfo) Sys() interface{} {
}
}
func
(
api
*
MfsAPI
)
Create
(
ctx
context
.
Context
,
path
coreiface
.
MfsPath
)
(
coreiface
.
File
,
error
)
{
func
(
api
*
MfsAPI
)
Create
(
ctx
context
.
Context
,
path
coreiface
.
MfsPath
)
(
coreiface
.
File
,
error
)
{
return
api
.
OpenFile
(
ctx
,
path
,
os
.
O_CREATE
|
os
.
O_WRONLY
,
defaultFilePerm
)
return
api
.
OpenFile
(
ctx
,
path
,
os
.
O_CREATE
|
os
.
O_WRONLY
,
defaultFilePerm
)
}
}
func
(
api
*
MfsAPI
)
Open
(
ctx
context
.
Context
,
path
coreiface
.
MfsPath
)
(
coreiface
.
File
,
error
)
{
func
(
api
*
MfsAPI
)
Open
(
ctx
context
.
Context
,
path
coreiface
.
MfsPath
)
(
coreiface
.
File
,
error
)
{
...
@@ -84,7 +84,6 @@ func (f *mfsFile) Close() error {
...
@@ -84,7 +84,6 @@ func (f *mfsFile) Close() error {
return
f
.
FileDescriptor
.
Close
()
return
f
.
FileDescriptor
.
Close
()
}
}
func
(
f
*
mfsFile
)
ReadAt
(
p
[]
byte
,
off
int64
)
(
int
,
error
)
{
func
(
f
*
mfsFile
)
ReadAt
(
p
[]
byte
,
off
int64
)
(
int
,
error
)
{
// TODO: implement in MFS with less locking
// TODO: implement in MFS with less locking
f
.
lk
.
Lock
()
f
.
lk
.
Lock
()
...
@@ -137,9 +136,9 @@ func (api *MfsAPI) OpenFile(ctx context.Context, path coreiface.MfsPath, flag in
...
@@ -137,9 +136,9 @@ func (api *MfsAPI) OpenFile(ctx context.Context, path coreiface.MfsPath, flag in
}
}
flags
:=
mfs
.
Flags
{
flags
:=
mfs
.
Flags
{
Read
:
flag
&
os
.
O_WRONLY
==
0
,
Read
:
flag
&
os
.
O_WRONLY
==
0
,
Write
:
flag
&
(
os
.
O_WRONLY
|
os
.
O_RDWR
)
!=
0
,
Write
:
flag
&
(
os
.
O_WRONLY
|
os
.
O_RDWR
)
!=
0
,
Sync
:
flag
&
os
.
O_SYNC
!=
0
,
Sync
:
flag
&
os
.
O_SYNC
!=
0
,
}
}
_
,
err
=
fn
.
Open
(
flags
)
_
,
err
=
fn
.
Open
(
flags
)
...
@@ -250,8 +249,8 @@ func (api *MfsAPI) ReadDir(ctx context.Context, path coreiface.MfsPath) ([]os.Fi
...
@@ -250,8 +249,8 @@ func (api *MfsAPI) ReadDir(ctx context.Context, path coreiface.MfsPath) ([]os.Fi
func
(
api
*
MfsAPI
)
MkdirAll
(
ctx
context
.
Context
,
path
coreiface
.
MfsPath
,
perm
os
.
FileMode
)
error
{
func
(
api
*
MfsAPI
)
MkdirAll
(
ctx
context
.
Context
,
path
coreiface
.
MfsPath
,
perm
os
.
FileMode
)
error
{
return
mfs
.
Mkdir
(
api
.
filesRoot
,
path
.
String
(),
mfs
.
MkdirOpts
{
return
mfs
.
Mkdir
(
api
.
filesRoot
,
path
.
String
(),
mfs
.
MkdirOpts
{
Mkparents
:
true
,
Mkparents
:
true
,
Flush
:
false
,
Flush
:
false
,
//CidBuilder: prefix, TODO
//CidBuilder: prefix, TODO
})
})
}
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论