提交 2106b4e3 作者: Łukasz Magiera

coreapi mfs: gofmt

License: MIT
Signed-off-by: 's avatarŁukasz Magiera <magik6k@gmail.com>
上级 65a7dbaf
...@@ -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
......
...@@ -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 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论