-
Notifications
You must be signed in to change notification settings - Fork 51
feat: files (mfs) api #54
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
package iface | ||
|
||
import ( | ||
"context" | ||
"io" | ||
|
||
"github.com/ipfs/go-cid" | ||
"github.com/ipfs/go-cidutil/cidenc" | ||
"github.com/ipfs/go-mfs" | ||
) | ||
|
||
type FilesCopyOptions struct { | ||
Flush bool | ||
} | ||
|
||
type FilesMoveOptions struct { | ||
Flush bool | ||
} | ||
|
||
type FilesListOptions struct { | ||
CidEncoder cidenc.Encoder | ||
Long bool | ||
} | ||
|
||
type FilesRemoveOptions struct { | ||
Force bool | ||
Recursive bool | ||
} | ||
|
||
type FilesStatOptions struct { | ||
CidEncoder cidenc.Encoder | ||
WithLocality bool | ||
} | ||
|
||
type FilesWriteOptions struct { | ||
Create bool | ||
MakeParents bool | ||
Truncate bool | ||
Flush bool | ||
RawLeaves bool | ||
RawLeavesOverride bool | ||
Offset int64 | ||
// Count is the number of bytes to write. 0 (default) writes everything. | ||
Count int64 | ||
CidBuilder cid.Builder | ||
} | ||
|
||
type FilesReadOptions struct { | ||
Offset int64 | ||
// Count is the number of bytes to read. 0 (default) reads everything. | ||
Count int64 | ||
} | ||
|
||
type FilesMkdirOptions struct { | ||
MakeParents bool | ||
Flush bool | ||
CidBuilder cid.Builder | ||
} | ||
|
||
type FilesChangeCidOptions struct { | ||
Flush bool | ||
CidBuilder cid.Builder | ||
} | ||
|
||
type FileInfo struct { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. docs |
||
Cid cid.Cid | ||
Size uint64 | ||
CumulativeSize uint64 | ||
Blocks int | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have no idea why we called this "blocks". Let's call it what it is, Children (NumChildren?). |
||
Type string | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please use the file types from |
||
WithLocality bool `json:",omitempty"` | ||
Local bool `json:",omitempty"` | ||
SizeLocal uint64 `json:",omitempty"` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hm. I remember not liking this when it first came up. Can we come up with a better (internal) API and translate back at the edges? I'll think about this a bit but proposals are very welcome. For historical context: ipfs/kubo#4638 |
||
} | ||
|
||
// FilesAPI specifies an interface to interact with the Mutable File System | ||
// layer. | ||
type FilesAPI interface { | ||
Copy(ctx context.Context, src, dst string, opts *FilesCopyOptions) error | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should use the functional options pattern we use in the other APIs. It allows us to add new complicated options (with logic) while retaining backwards compatibility. See: https://dave.cheney.net/2014/10/17/functional-options-for-friendly-apis |
||
Move(ctx context.Context, src, dst string, opts *FilesMoveOptions) error | ||
List(ctx context.Context, path string, opts *FilesListOptions) ([]mfs.NodeListing, error) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's make this streaming from the start. See #49 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's re-use the return type from |
||
Remove(ctx context.Context, path string, opts *FilesRemoveOptions) error | ||
Stat(ctx context.Context, path string, opts *FilesStatOptions) (*FileInfo, error) | ||
Read(ctx context.Context, path string, opts *FilesReadOptions) (io.ReadCloser, error) | ||
Write(ctx context.Context, path string, r io.Reader, opts *FilesWriteOptions) error | ||
Mkdir(ctx context.Context, path string, opts *FilesMkdirOptions) error | ||
Flush(ctx context.Context, path string) (cid.Cid, error) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,25 @@ | ||
module github.com/ipfs/interface-go-ipfs-core | ||
|
||
require ( | ||
github.com/fd/go-nat v1.0.0 // indirect | ||
github.com/gxed/pubsub v0.0.0-20180201040156-26ebdf44f824 // indirect | ||
github.com/ipfs/go-cid v0.0.3 | ||
github.com/ipfs/go-ipfs-files v0.0.2 | ||
github.com/ipfs/go-ipld-cbor v0.0.1 | ||
github.com/ipfs/go-ipld-format v0.0.1 | ||
github.com/ipfs/go-merkledag v0.0.3 | ||
github.com/ipfs/go-path v0.0.3 | ||
github.com/ipfs/go-unixfs v0.0.4 | ||
github.com/ipfs/go-cidutil v0.0.2 | ||
github.com/ipfs/go-ipfs-files v0.0.3 | ||
github.com/ipfs/go-ipfs-flags v0.0.1 // indirect | ||
github.com/ipfs/go-ipld-cbor v0.0.2 | ||
github.com/ipfs/go-ipld-format v0.0.2 | ||
github.com/ipfs/go-merkledag v0.1.0 | ||
github.com/ipfs/go-mfs v0.1.1 | ||
github.com/ipfs/go-path v0.0.7 | ||
github.com/ipfs/go-unixfs v0.1.0 | ||
github.com/libp2p/go-libp2p-core v0.2.2 | ||
github.com/multiformats/go-multiaddr v0.0.4 | ||
github.com/multiformats/go-multihash v0.0.7 | ||
github.com/whyrusleeping/go-smux-multiplex v3.0.16+incompatible // indirect | ||
github.com/whyrusleeping/go-smux-multistream v2.0.2+incompatible // indirect | ||
github.com/whyrusleeping/go-smux-yamux v2.0.9+incompatible // indirect | ||
github.com/whyrusleeping/yamux v1.1.5 // indirect | ||
) | ||
|
||
go 1.12 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Docs. Lots of docs.