mirror of
https://github.com/ipfs/kubo.git
synced 2026-02-21 10:27:46 +08:00
files2.0: address review
License: MIT Signed-off-by: Łukasz Magiera <magik6k@gmail.com>
This commit is contained in:
parent
1fe28bc658
commit
a2f15faa4c
@ -87,15 +87,19 @@ environment variable:
|
||||
f := req.Files
|
||||
if f != nil {
|
||||
it := req.Files.Entries()
|
||||
if !it.Next() && it.Err() != nil {
|
||||
return it.Err()
|
||||
if !it.Next() {
|
||||
if it.Err() != nil {
|
||||
return it.Err()
|
||||
}
|
||||
return fmt.Errorf("file argument was nil")
|
||||
}
|
||||
if files.FileFromEntry(it) == nil {
|
||||
file := files.FileFromEntry(it)
|
||||
if file == nil {
|
||||
return fmt.Errorf("expected a regular file")
|
||||
}
|
||||
|
||||
conf = &config.Config{}
|
||||
if err := json.NewDecoder(files.FileFromEntry(it)).Decode(conf); err != nil {
|
||||
if err := json.NewDecoder(file).Decode(conf); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
@ -130,7 +130,7 @@ func cat(ctx context.Context, api iface.CoreAPI, paths []string, offset int64, m
|
||||
|
||||
file, ok := f.(files.File)
|
||||
if !ok {
|
||||
return nil, 0, iface.ErrIsDir
|
||||
return nil, 0, iface.ErrNotFile
|
||||
}
|
||||
|
||||
fsize, err := file.Size()
|
||||
|
||||
@ -6,6 +6,7 @@ import (
|
||||
files "gx/ipfs/QmXWZCd8jfaHmt4UDSnjKmGcrQMw95bDGWqEeVLVJjoANX/go-ipfs-files"
|
||||
)
|
||||
|
||||
// GetFileArg returns the next file from the directory or an error
|
||||
func GetFileArg(it files.DirIterator) (files.File, error) {
|
||||
if !it.Next() {
|
||||
err := it.Err()
|
||||
|
||||
@ -4,5 +4,6 @@ import "errors"
|
||||
|
||||
var (
|
||||
ErrIsDir = errors.New("this dag node is a directory")
|
||||
ErrNotFile = errors.New("this dag node is not a regular file")
|
||||
ErrOffline = errors.New("this action must be run in online mode, try running 'ipfs daemon' first")
|
||||
)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user