mirror of
https://github.com/ipfs/kubo.git
synced 2026-02-21 10:27:46 +08:00
coreapi mfs: gofmt
License: MIT Signed-off-by: Łukasz Magiera <magik6k@gmail.com>
This commit is contained in:
parent
65a7dbaf97
commit
2106b4e3b1
@ -72,7 +72,7 @@ type CoreAPI struct {
|
||||
checkPublishAllowed func() 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
|
||||
nd *core.IpfsNode
|
||||
|
||||
@ -2,15 +2,15 @@ package coreapi
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/ipfs/go-mfs"
|
||||
"github.com/pkg/errors"
|
||||
"io"
|
||||
"os"
|
||||
gopath "path"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/ipfs/go-mfs"
|
||||
coreiface "github.com/ipfs/interface-go-ipfs-core"
|
||||
)
|
||||
|
||||
@ -19,7 +19,7 @@ const defaultDirPerm = 0755
|
||||
|
||||
type MfsAPI CoreAPI
|
||||
|
||||
type fileNodeInfo struct{
|
||||
type fileNodeInfo struct {
|
||||
l mfs.NodeListing
|
||||
}
|
||||
|
||||
@ -48,7 +48,7 @@ func (i *fileNodeInfo) Sys() interface{} {
|
||||
}
|
||||
|
||||
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) {
|
||||
@ -84,7 +84,6 @@ func (f *mfsFile) Close() error {
|
||||
return f.FileDescriptor.Close()
|
||||
}
|
||||
|
||||
|
||||
func (f *mfsFile) ReadAt(p []byte, off int64) (int, error) {
|
||||
// TODO: implement in MFS with less locking
|
||||
f.lk.Lock()
|
||||
@ -137,9 +136,9 @@ func (api *MfsAPI) OpenFile(ctx context.Context, path coreiface.MfsPath, flag in
|
||||
}
|
||||
|
||||
flags := mfs.Flags{
|
||||
Read: flag & os.O_WRONLY == 0,
|
||||
Write: flag & (os.O_WRONLY | os.O_RDWR) != 0,
|
||||
Sync: flag & os.O_SYNC != 0,
|
||||
Read: flag&os.O_WRONLY == 0,
|
||||
Write: flag&(os.O_WRONLY|os.O_RDWR) != 0,
|
||||
Sync: flag&os.O_SYNC != 0,
|
||||
}
|
||||
|
||||
_, err = fn.Open(flags)
|
||||
@ -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 {
|
||||
return mfs.Mkdir(api.filesRoot, path.String(), mfs.MkdirOpts{
|
||||
Mkparents: true,
|
||||
Flush: false,
|
||||
Mkparents: true,
|
||||
Flush: false,
|
||||
//CidBuilder: prefix, TODO
|
||||
})
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user