Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Special-case accepting explicitly supplied named pipes #184

Merged
merged 4 commits into from
Mar 16, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# go-ipfs changelog

- Accept named fifos ( pipes ) when supplied directly as an argument, continues to reject them when encountered recursively
ribasushi marked this conversation as resolved.
Show resolved Hide resolved
- Require Go 1.14
- Remove gx

### 0.4.4 - 2016-10-11
Expand Down
13 changes: 11 additions & 2 deletions cli/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (
"strings"

osh "github.com/Kubuxu/go-os-helper"
"github.com/ipfs/go-ipfs-cmds"
"github.com/ipfs/go-ipfs-files"
cmds "github.com/ipfs/go-ipfs-cmds"
files "github.com/ipfs/go-ipfs-files"
logging "github.com/ipfs/go-log"
)

Expand Down Expand Up @@ -510,6 +510,15 @@ func appendFile(fpath string, argDef *cmds.Argument, recursive, hidden bool) (fi
if !recursive {
return nil, fmt.Errorf(notRecursiveFmtStr, fpath, cmds.RecShort)
}
} else if (stat.Mode() & os.ModeNamedPipe) != 0 {
// Special case pipes that are provided directly on the command line
// We do this here instead of go-ipfs-files, as we need to differentiate between
// recursive(unsupported) and direct(supported) mode
file, err := os.Open(fpath)
if err != nil {
return nil, err
}
return files.NewReaderPathFile(fpath, file, stat)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The path & stat should be nil.

  • The path should only refer to files that can actually be read. The filestore/urlstore features will use it.
  • The stat will be used to determine the size of the file. It'll give us very incorrect information in this case.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

path is a string, so I went with "" ( thought of using newMessageReader but proably incorrect in this case ). There were zero changes needed in the go-ipfs test suite ( aside from ipfs/kubo#6998 obviously ), so this seems like the right thing to do.

}

return files.NewSerialFile(fpath, hidden, stat)
Expand Down