Skip to content

Commit

Permalink
merge ipfs v0.7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Robin committed Dec 7, 2020
2 parents 8e55349 + ea77213 commit 34b7e35
Show file tree
Hide file tree
Showing 102 changed files with 4,475 additions and 1,406 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,9 @@ go-ipfs-source.tar.gz

docs/examples/go-ipfs-as-a-library/example-folder/Qm*
/test/sharness/t0054-dag-car-import-export-data/*.car

# ignore build output from snapcraft
/ipfs_*.snap
/parts
/stage
/prime
539 changes: 539 additions & 0 deletions CHANGELOG.md

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ ENV TINI_VERSION v0.19.0
RUN set -eux; \
dpkgArch="$(dpkg --print-architecture)"; \
case "${dpkgArch##*-}" in \
"amd64" | "armhf" | "arm64") tiniArch="tini-$dpkgArch" ;;\
"amd64" | "armhf" | "arm64") tiniArch="tini-static-$dpkgArch" ;;\
*) echo >&2 "unsupported architecture: ${dpkgArch}"; exit 1 ;; \
esac; \
cd /tmp \
&& git clone https://github.com/ncopa/su-exec.git \
&& cd su-exec \
&& git checkout -q $SUEXEC_VERSION \
&& make \
&& make su-exec-static \
&& cd /tmp \
&& wget -q -O tini https://github.com/krallin/tini/releases/download/$TINI_VERSION/$tiniArch \
&& chmod +x tini
Expand All @@ -60,7 +60,7 @@ MAINTAINER TRON-US <support@tron.network>
ENV SRC_DIR /go-btfs
COPY --from=0 $SRC_DIR/cmd/btfs/btfs /usr/local/bin/btfs
COPY --from=0 $SRC_DIR/bin/container_daemon /usr/local/bin/start_btfs
COPY --from=0 /tmp/su-exec/su-exec /sbin/su-exec
COPY --from=0 /tmp/su-exec/su-exec-static /sbin/su-exec
COPY --from=0 /tmp/tini /sbin/tini
COPY --from=0 /bin/fusermount /usr/local/bin/fusermount
COPY --from=0 /etc/ssl/certs /etc/ssl/certs
Expand Down
1 change: 1 addition & 0 deletions assets/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ commit.
```bash
> go generate .
> git add bindata.go
> git add bindata_version_hash.go
> go mod tidy
> git commit --amend --no-edit

Expand Down
2 changes: 1 addition & 1 deletion assets/assets.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//go:generate git submodule update --init ./dir-index-html
//go:generate go run github.com/go-bindata/go-bindata/go-bindata -pkg=assets init-doc dir-index-html/dir-index.html dir-index-html/knownIcons.txt
//go:generate go run github.com/go-bindata/go-bindata/v3/go-bindata -mode=0644 -modtime=1403768328 -pkg=assets init-doc dir-index-html/dir-index.html dir-index-html/knownIcons.txt
//go:generate gofmt -w bindata.go
//go:generate sh -c "sed -i \"s/.*BindataVersionHash.*/BindataVersionHash=\\\"$(git hash-object bindata.go)\\\"/\" bindata_version_hash.go"
//go:generate gofmt -w bindata_version_hash.go
Expand Down
22 changes: 11 additions & 11 deletions assets/bindata.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion assets/dir-index-html
Submodule dir-index-html deleted from 3b602e
15 changes: 11 additions & 4 deletions bin/mkreleaselog
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,22 @@ AUTHORS=(

NL=$'\n'

ROOT_DIR="$(git rev-parse --show-toplevel)"

msg() {
echo "$*" >&2
}

statlog() {
rpath="$GOPATH/src/$1"
start="${2:-}"
end="${3:-HEAD}"
git -C "$rpath" log --shortstat --no-merges --pretty="tformat:%H%n%aN%n%aE" "$start..$end" | while
local rpath="$GOPATH/src/$1"
local start="${2:-}"
local end="${3:-HEAD}"
local mailmap_file="$rpath/.mailmap"
if ! [[ -e "$mailmap_file" ]]; then
mailmap_file="$ROOT_DIR/.mailmap"
fi

git -C "$rpath" -c mailmap.file="$mailmap_file" log --use-mailmap --shortstat --no-merges --pretty="tformat:%H%n%aN%n%aE" "$start..$end" | while
read hash
read name
read email
Expand Down
2 changes: 1 addition & 1 deletion cmd/btfs/btfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package main
import (
"fmt"

"github.com/TRON-US/go-btfs/core/commands"
commands "github.com/TRON-US/go-btfs/core/commands"

cmds "github.com/TRON-US/go-btfs-cmds"
)
Expand Down
6 changes: 4 additions & 2 deletions cmd/btfs/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ import (
multierror "github.com/hashicorp/go-multierror"
util "github.com/ipfs/go-ipfs-util"
mprome "github.com/ipfs/go-metrics-prometheus"
"github.com/jbenet/goprocess"
goprocess "github.com/jbenet/goprocess"
sockets "github.com/libp2p/go-socket-activation"
ma "github.com/multiformats/go-multiaddr"
manet "github.com/multiformats/go-multiaddr-net"
manet "github.com/multiformats/go-multiaddr/net"
prometheus "github.com/prometheus/client_golang/prometheus"
promauto "github.com/prometheus/client_golang/prometheus/promauto"
nodepb "github.com/tron-us/go-btfs-common/protos/node"
Expand Down Expand Up @@ -206,6 +206,8 @@ Headers.
// cmds.StringOption(swarmAddrKwd, "Address for the swarm socket (overrides config)"),
},
Subcommands: map[string]*cmds.Command{},
NoRemote: true,
Extra: commands.CreateCmdExtras(commands.SetDoesNotUseConfigAsInput(true)),
Run: daemonFunc,
}

Expand Down
5 changes: 4 additions & 1 deletion cmd/btfs/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ import (
"github.com/TRON-US/go-btfs/cmd/btfs/util"
oldcmds "github.com/TRON-US/go-btfs/commands"
"github.com/TRON-US/go-btfs/core"
"github.com/TRON-US/go-btfs/core/commands"
"github.com/TRON-US/go-btfs/namesys"
"github.com/TRON-US/go-btfs/repo/fsrepo"
fsrepo "github.com/TRON-US/go-btfs/repo/fsrepo"

cmds "github.com/TRON-US/go-btfs-cmds"
config "github.com/TRON-US/go-btfs-config"
Expand Down Expand Up @@ -69,6 +70,8 @@ environment variable:
// name of the file?
// TODO cmds.StringOption("event-logs", "l", "Location for machine-readable event logs."),
},
NoRemote: true,
Extra: commands.CreateCmdExtras(commands.SetDoesNotUseRepo(true), commands.SetDoesNotUseConfigAsInput(true)),
PreRun: func(req *cmds.Request, env cmds.Environment) error {
cctx := env.(*oldcmds.Context)
daemonLocked, err := fsrepo.LockedByOtherProcess(cctx.ConfigRoot)
Expand Down
32 changes: 8 additions & 24 deletions cmd/btfs/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"net/http"
"os"
"runtime/pprof"
"strings"
"time"

util "github.com/TRON-US/go-btfs/cmd/btfs/util"
Expand All @@ -31,7 +30,7 @@ import (
loggables "github.com/libp2p/go-libp2p-loggables"
ma "github.com/multiformats/go-multiaddr"
madns "github.com/multiformats/go-multiaddr-dns"
manet "github.com/multiformats/go-multiaddr-net"
manet "github.com/multiformats/go-multiaddr/net"
)

// log is the command logger
Expand Down Expand Up @@ -202,16 +201,17 @@ func apiAddrOption(req *cmds.Request) (ma.Multiaddr, error) {
func makeExecutor(req *cmds.Request, env interface{}) (cmds.Executor, error) {
exe := cmds.NewExecutor(req.Root)
cctx := env.(*oldcmds.Context)
details := commandDetails(req.Path)

// Check if the command is disabled.
if details.cannotRunOnClient && details.cannotRunOnDaemon {
if req.Command.NoLocal && req.Command.NoRemote {
return nil, fmt.Errorf("command disabled: %v", req.Path)
}

// Can we just run this locally?
if !details.cannotRunOnClient && details.doesNotUseRepo {
return exe, nil
if !req.Command.NoLocal {
if doesNotUseRepo, ok := corecmds.GetDoesNotUseRepo(req.Command.Extra); doesNotUseRepo && ok {
return exe, nil
}
}

// Get the API option from the commandline.
Expand All @@ -225,7 +225,7 @@ func makeExecutor(req *cmds.Request, env interface{}) (cmds.Executor, error) {
daemonRequested := apiAddr != nil && req.Command != daemonCmd

// Run this on the client if required.
if details.cannotRunOnDaemon || req.Command.External {
if req.Command.NoRemote {
if daemonRequested {
// User requested that the command be run on the daemon but we can't.
// NOTE: We drop this check for the `ipfs daemon` command.
Expand All @@ -247,7 +247,7 @@ func makeExecutor(req *cmds.Request, env interface{}) (cmds.Executor, error) {

// Still no api specified? Run it on the client or fail.
if apiAddr == nil {
if details.cannotRunOnClient {
if req.Command.NoLocal {
return nil, fmt.Errorf("command must be run on the daemon: %v", req.Path)
}
return exe, nil
Expand Down Expand Up @@ -293,22 +293,6 @@ func makeExecutor(req *cmds.Request, env interface{}) (cmds.Executor, error) {
return cmdhttp.NewClient(host, opts...), nil
}

// commandDetails returns a command's details for the command given by |path|.
func commandDetails(path []string) cmdDetails {
if len(path) == 0 {
// special case root command
return cmdDetails{doesNotUseRepo: true}
}
var details cmdDetails
// find the last command in path that has a cmdDetailsMap entry
for i := range path {
if cmdDetails, found := cmdDetailsMap[strings.Join(path[:i+1], "/")]; found {
details = cmdDetails
}
}
return details
}

func getRepoPath(req *cmds.Request) (string, error) {
repoOpt, found := req.Options["config"].(string)
if found && repoOpt != "" {
Expand Down
1 change: 1 addition & 0 deletions core/commands/active.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ var ActiveReqsCmd = &cmds.Command{
Lists running and recently run commands.
`,
},
NoLocal: true,
Run: func(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environment) error {
ctx := env.(*oldcmds.Context)
return cmds.EmitOnce(res, ctx.ReqLog.Report())
Expand Down
4 changes: 4 additions & 0 deletions core/commands/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ Adds contents of <path> to btfs. Use -r to add directories.
Note that directories are added recursively, to form the btfs
MerkleDAG.
If the daemon is not running, it will just add locally.
If the daemon is started later, it will be advertised after a few
seconds when the reprovider runs.
The wrap option, '-w', wraps the file (or files, if using the
recursive option) in a directory. This directory contains only
the files which have been added, and means that the file retains
Expand Down
1 change: 1 addition & 0 deletions core/commands/cid.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ var CidCmd = &cmds.Command{
"codecs": codecsCmd,
"hashes": hashesCmd,
},
Extra: CreateCmdExtras(SetDoesNotUseRepo(true)),
}

const (
Expand Down
32 changes: 16 additions & 16 deletions core/commands/cmdenv/cidbase_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ func TestEncoderFromPath(t *testing.T) {
test(p+"/a/b", enc)
test(p+"/a/b/", enc)
test(p+"/a/b/c", enc)
test("/ipfs/"+p, enc)
test("/ipfs/"+p+"/b", enc)
test("/btfs/"+p, enc)
test("/btfs/"+p+"/b", enc)

p = "zb2rhfkM4FjkMLaUnygwhuqkETzbYXnUDf1P9MSmdNjW1w1Lk"
enc = cidenc.Encoder{
Expand All @@ -37,30 +37,30 @@ func TestEncoderFromPath(t *testing.T) {
test(p+"/a/b", enc)
test(p+"/a/b/", enc)
test(p+"/a/b/c", enc)
test("/ipfs/"+p, enc)
test("/ipfs/"+p+"/b", enc)
test("/ipld/"+p, enc)
test("/ipns/"+p, enc) // even IPNS should work.
test("/btfs/"+p, enc)
test("/btfs/"+p+"/b", enc)
test("/btld/"+p, enc)
test("/btns/"+p, enc) // even IPNS should work.

p = "bafyreifrcnyjokuw4i4ggkzg534tjlc25lqgt3ttznflmyv5fftdgu52hm"
enc = cidenc.Encoder{
Base: mbase.MustNewEncoder(mbase.Base32),
Upgrade: true,
}
test(p, enc)
test("/ipfs/"+p, enc)
test("/ipld/"+p, enc)
test("/btfs/"+p, enc)
test("/btld/"+p, enc)

for _, badPath := range []string{
"/ipld/",
"/ipld",
"/ipld//",
"ipld//",
"ipld",
"/btld/",
"/btld",
"/btld//",
"btld//",
"btld",
"",
"ipns",
"/ipfs/asdf",
"/ipfs/...",
"btns",
"/btfs/asdf",
"/btfs/...",
"...",
"abcdefg",
"boo",
Expand Down
Loading

0 comments on commit 34b7e35

Please sign in to comment.