From 0618fd77beb88e1ac70b8a2d2c12ca95fde2d7ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Fri, 26 Oct 2018 14:14:49 +0200 Subject: [PATCH 01/16] gx: update go-ipfs-files to 2.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit License: MIT Signed-off-by: Łukasz Magiera --- assets/assets.go | 2 +- cmd/ipfs/daemon.go | 2 +- cmd/ipfs/init.go | 2 +- cmd/ipfs/ipfs.go | 2 +- cmd/ipfs/main.go | 6 +++--- commands/context.go | 2 +- core/builder.go | 2 +- core/commands/active.go | 2 +- core/commands/add.go | 4 ++-- core/commands/bitswap.go | 2 +- core/commands/block.go | 2 +- core/commands/bootstrap.go | 2 +- core/commands/cat.go | 2 +- core/commands/cid.go | 2 +- core/commands/cmdenv/env.go | 2 +- core/commands/commands.go | 2 +- core/commands/commands_test.go | 2 +- core/commands/config.go | 2 +- core/commands/dag/dag.go | 2 +- core/commands/dht.go | 2 +- core/commands/diag.go | 2 +- core/commands/dns.go | 2 +- core/commands/external.go | 2 +- core/commands/files.go | 6 +++--- core/commands/filestore.go | 2 +- core/commands/get.go | 4 ++-- core/commands/get_test.go | 2 +- core/commands/helptext_test.go | 2 +- core/commands/id.go | 2 +- core/commands/keystore.go | 2 +- core/commands/log.go | 2 +- core/commands/ls.go | 8 ++++---- core/commands/mount_nofuse.go | 2 +- core/commands/mount_unix.go | 2 +- core/commands/mount_windows.go | 2 +- core/commands/name/ipns.go | 2 +- core/commands/name/ipnsps.go | 2 +- core/commands/name/name.go | 2 +- core/commands/name/publish.go | 2 +- core/commands/object/diff.go | 2 +- core/commands/object/object.go | 2 +- core/commands/object/patch.go | 2 +- core/commands/p2p.go | 2 +- core/commands/pin.go | 2 +- core/commands/ping.go | 2 +- core/commands/pubsub.go | 2 +- core/commands/refs.go | 2 +- core/commands/repo.go | 2 +- core/commands/resolve.go | 2 +- core/commands/root.go | 2 +- core/commands/shutdown.go | 2 +- core/commands/stat.go | 2 +- core/commands/swarm.go | 2 +- core/commands/sysdiag.go | 2 +- core/commands/tar.go | 2 +- core/commands/unixfs/ls.go | 4 ++-- core/commands/unixfs/unixfs.go | 2 +- core/commands/urlstore.go | 8 ++++---- core/commands/version.go | 2 +- core/core.go | 4 ++-- core/coreapi/interface/unixfs.go | 2 +- core/coreapi/name_test.go | 2 +- core/coreapi/object.go | 2 +- core/coreapi/path.go | 2 +- core/coreapi/unixfile.go | 6 +++--- core/coreapi/unixfs.go | 8 ++++---- core/coreapi/unixfs_test.go | 4 ++-- core/corehttp/commands.go | 4 ++-- core/corehttp/gateway_handler.go | 8 ++++---- core/corerepo/gc.go | 2 +- core/coreunix/add.go | 12 ++++++------ core/coreunix/add_test.go | 2 +- core/coreunix/metadata.go | 2 +- core/coreunix/metadata_test.go | 6 +++--- fuse/ipns/common.go | 2 +- fuse/ipns/ipns_unix.go | 4 ++-- fuse/readonly/ipfs_test.go | 4 ++-- fuse/readonly/readonly_unix.go | 4 ++-- namesys/namesys_test.go | 2 +- namesys/publisher.go | 2 +- package.json | 16 ++++++++-------- tar/format.go | 4 ++-- 82 files changed, 124 insertions(+), 124 deletions(-) diff --git a/assets/assets.go b/assets/assets.go index 0eb413d2a61..9c81f84414e 100644 --- a/assets/assets.go +++ b/assets/assets.go @@ -12,7 +12,7 @@ import ( "github.com/ipfs/go-ipfs/core" "github.com/ipfs/go-ipfs/core/coreunix" cid "gx/ipfs/QmR8BauakNcBa3RbE4nbQu76PDiJgoQgz8AJdhJuiU4TAw/go-cid" - uio "gx/ipfs/QmdYvDbHp7qAhZ7GsCj6e1cMo55ND6y2mjWVzwdvcv4f12/go-unixfs/io" + uio "gx/ipfs/Qmbvw7kpSM2p6rbQ57WGRhhqNfCiNGW6EKH4xgHLw4bsnB/go-unixfs/io" // this import keeps gx from thinking the dep isn't used _ "gx/ipfs/QmdZ4PvPHFQVLLEve7DgoKDcSY19wwpGBB1GKjjKi2rEL1/dir-index-html" diff --git a/cmd/ipfs/daemon.go b/cmd/ipfs/daemon.go index a896a96ac3e..a1be01c6d4b 100644 --- a/cmd/ipfs/daemon.go +++ b/cmd/ipfs/daemon.go @@ -23,11 +23,11 @@ import ( fsrepo "github.com/ipfs/go-ipfs/repo/fsrepo" migrate "github.com/ipfs/go-ipfs/repo/fsrepo/migrations" - cmds "gx/ipfs/QmPdvMtgpnMuU68mWhGtzCxnddXJoV96tT9aPcNbQsqPaM/go-ipfs-cmds" "gx/ipfs/QmQVUtnrNGtCRkCMpXgpApfzQjc8FDaDVxHqWH8cnZQeh5/go-multiaddr-net" ma "gx/ipfs/QmRKLtwMw131aK7ugC3G7ybpumMz78YrJe5dzneyindvG1/go-multiaddr" "gx/ipfs/QmTQuFQWHAWy4wMH6ZyPfGiawA5u9T8rs79FENoV8yXaoS/client_golang/prometheus" mprome "gx/ipfs/QmVMcMs6duiwLzvhF6xWM3yc4GgjpNoctKFhvtBch5tpgo/go-metrics-prometheus" + cmds "gx/ipfs/QmaAP56JAwdjwisPTu4yx17whcjTr6y5JCSCF77Y1rahWV/go-ipfs-cmds" "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit" ) diff --git a/cmd/ipfs/init.go b/cmd/ipfs/init.go index 53367f5de0f..fa25eb5d743 100644 --- a/cmd/ipfs/init.go +++ b/cmd/ipfs/init.go @@ -16,8 +16,8 @@ import ( namesys "github.com/ipfs/go-ipfs/namesys" fsrepo "github.com/ipfs/go-ipfs/repo/fsrepo" - "gx/ipfs/QmPdvMtgpnMuU68mWhGtzCxnddXJoV96tT9aPcNbQsqPaM/go-ipfs-cmds" "gx/ipfs/QmYyzmMnhNTtoXx5ttgUaRdHHckYnQWjPL98hgLAR2QLDD/go-ipfs-config" + "gx/ipfs/QmaAP56JAwdjwisPTu4yx17whcjTr6y5JCSCF77Y1rahWV/go-ipfs-cmds" "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit" ) diff --git a/cmd/ipfs/ipfs.go b/cmd/ipfs/ipfs.go index e05058476d7..316112e52f0 100644 --- a/cmd/ipfs/ipfs.go +++ b/cmd/ipfs/ipfs.go @@ -5,7 +5,7 @@ import ( commands "github.com/ipfs/go-ipfs/core/commands" - cmds "gx/ipfs/QmPdvMtgpnMuU68mWhGtzCxnddXJoV96tT9aPcNbQsqPaM/go-ipfs-cmds" + cmds "gx/ipfs/QmaAP56JAwdjwisPTu4yx17whcjTr6y5JCSCF77Y1rahWV/go-ipfs-cmds" ) // This is the CLI root, used for executing commands accessible to CLI clients. diff --git a/cmd/ipfs/main.go b/cmd/ipfs/main.go index 9c8b1262a08..59e0bb3b894 100644 --- a/cmd/ipfs/main.go +++ b/cmd/ipfs/main.go @@ -25,15 +25,15 @@ import ( fsrepo "github.com/ipfs/go-ipfs/repo/fsrepo" u "gx/ipfs/QmNohiVssaPw3KVLZik59DBVGTSm2dGvYT9eoXt5DQ36Yz/go-ipfs-util" - "gx/ipfs/QmPdvMtgpnMuU68mWhGtzCxnddXJoV96tT9aPcNbQsqPaM/go-ipfs-cmds" - "gx/ipfs/QmPdvMtgpnMuU68mWhGtzCxnddXJoV96tT9aPcNbQsqPaM/go-ipfs-cmds/cli" - "gx/ipfs/QmPdvMtgpnMuU68mWhGtzCxnddXJoV96tT9aPcNbQsqPaM/go-ipfs-cmds/http" loggables "gx/ipfs/QmQSREHX6CMoPkT5FfuA4A9cWSFwoKY8RAzjf5m7Gpdtqu/go-libp2p-loggables" manet "gx/ipfs/QmQVUtnrNGtCRkCMpXgpApfzQjc8FDaDVxHqWH8cnZQeh5/go-multiaddr-net" ma "gx/ipfs/QmRKLtwMw131aK7ugC3G7ybpumMz78YrJe5dzneyindvG1/go-multiaddr" madns "gx/ipfs/QmT4zgnKCyZBpRyxzsvZqUjzUkMWLJ2pZCw7uk6M6Kto5m/go-multiaddr-dns" osh "gx/ipfs/QmXuBJ7DR6k3rmUEKtvVMhwjmXDuJgXXPUt4LQXKBMsU93/go-os-helper" "gx/ipfs/QmYyzmMnhNTtoXx5ttgUaRdHHckYnQWjPL98hgLAR2QLDD/go-ipfs-config" + "gx/ipfs/QmaAP56JAwdjwisPTu4yx17whcjTr6y5JCSCF77Y1rahWV/go-ipfs-cmds" + "gx/ipfs/QmaAP56JAwdjwisPTu4yx17whcjTr6y5JCSCF77Y1rahWV/go-ipfs-cmds/cli" + "gx/ipfs/QmaAP56JAwdjwisPTu4yx17whcjTr6y5JCSCF77Y1rahWV/go-ipfs-cmds/http" logging "gx/ipfs/QmcuXC5cxs79ro2cUuHs4HQ2bkDLJUYokwL8aivcX6HW3C/go-log" ) diff --git a/commands/context.go b/commands/context.go index 8d14e3b2a29..41d6b05d087 100644 --- a/commands/context.go +++ b/commands/context.go @@ -11,8 +11,8 @@ import ( coreiface "github.com/ipfs/go-ipfs/core/coreapi/interface" loader "github.com/ipfs/go-ipfs/plugin/loader" - "gx/ipfs/QmPdvMtgpnMuU68mWhGtzCxnddXJoV96tT9aPcNbQsqPaM/go-ipfs-cmds" config "gx/ipfs/QmYyzmMnhNTtoXx5ttgUaRdHHckYnQWjPL98hgLAR2QLDD/go-ipfs-config" + "gx/ipfs/QmaAP56JAwdjwisPTu4yx17whcjTr6y5JCSCF77Y1rahWV/go-ipfs-cmds" logging "gx/ipfs/QmcuXC5cxs79ro2cUuHs4HQ2bkDLJUYokwL8aivcX6HW3C/go-log" ) diff --git a/core/builder.go b/core/builder.go index ebee4efaab1..e4a8f673c27 100644 --- a/core/builder.go +++ b/core/builder.go @@ -28,8 +28,8 @@ import ( pstore "gx/ipfs/QmZ9zH2FnLcxv1xyzFeUpDUeo55xEhZQHgveZijcxr7TLj/go-libp2p-peerstore" pstoremem "gx/ipfs/QmZ9zH2FnLcxv1xyzFeUpDUeo55xEhZQHgveZijcxr7TLj/go-libp2p-peerstore/pstoremem" resolver "gx/ipfs/QmZErC2Ay6WuGi96CPg316PwitdwgLo6RxZRqVjJjRj2MR/go-path/resolver" + uio "gx/ipfs/Qmbvw7kpSM2p6rbQ57WGRhhqNfCiNGW6EKH4xgHLw4bsnB/go-unixfs/io" dag "gx/ipfs/QmdV35UHnL1FM52baPkeUo6u7Fxm2CRUkPTLRPxeF8a4Ap/go-merkledag" - uio "gx/ipfs/QmdYvDbHp7qAhZ7GsCj6e1cMo55ND6y2mjWVzwdvcv4f12/go-unixfs/io" offroute "gx/ipfs/QmdmWkx54g7VfVyxeG8ic84uf4G6Eq1GohuyKA3XDuJ8oC/go-ipfs-routing/offline" metrics "gx/ipfs/QmekzFM3hPZjTjUFGTABdQkEnQ3PTiMstY198PwSFr5w1Q/go-metrics-interface" ds "gx/ipfs/Qmf4xQhNomPNhrtZc67qSnfJSjxjXs9LWvknJtSXwimPrM/go-datastore" diff --git a/core/commands/active.go b/core/commands/active.go index 0d6f069ea7b..bdab3d9b548 100644 --- a/core/commands/active.go +++ b/core/commands/active.go @@ -9,7 +9,7 @@ import ( oldcmds "github.com/ipfs/go-ipfs/commands" - cmds "gx/ipfs/QmPdvMtgpnMuU68mWhGtzCxnddXJoV96tT9aPcNbQsqPaM/go-ipfs-cmds" + cmds "gx/ipfs/QmaAP56JAwdjwisPTu4yx17whcjTr6y5JCSCF77Y1rahWV/go-ipfs-cmds" cmdkit "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit" ) diff --git a/core/commands/add.go b/core/commands/add.go index 6e1b63dc11b..d78bad32398 100644 --- a/core/commands/add.go +++ b/core/commands/add.go @@ -10,9 +10,9 @@ import ( coreiface "github.com/ipfs/go-ipfs/core/coreapi/interface" options "github.com/ipfs/go-ipfs/core/coreapi/interface/options" - cmds "gx/ipfs/QmPdvMtgpnMuU68mWhGtzCxnddXJoV96tT9aPcNbQsqPaM/go-ipfs-cmds" pb "gx/ipfs/QmPtj12fdwuAqj9sBSTNUxBNu8kCGNp8b3o8yUzMm5GHpq/pb" - files "gx/ipfs/QmZMWMvWMVKCbHetJ4RgndbuEF1io2UpUxwQwtNjtYPzSC/go-ipfs-files" + files "gx/ipfs/QmXWZCd8jfaHmt4UDSnjKmGcrQMw95bDGWqEeVLVJjoANX/go-ipfs-files" + cmds "gx/ipfs/QmaAP56JAwdjwisPTu4yx17whcjTr6y5JCSCF77Y1rahWV/go-ipfs-cmds" cmdkit "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit" mh "gx/ipfs/QmerPMzPk1mJVowm8KgmoknWa4yCYvvugMPsgWmDNUvDLW/go-multihash" ) diff --git a/core/commands/bitswap.go b/core/commands/bitswap.go index 79f14b67a3f..cd99c19469c 100644 --- a/core/commands/bitswap.go +++ b/core/commands/bitswap.go @@ -8,10 +8,10 @@ import ( e "github.com/ipfs/go-ipfs/core/commands/e" humanize "gx/ipfs/QmPSBJL4momYnE7DcUyk2DVhD6rH488ZmHBGLbxNdhU44K/go-humanize" - cmds "gx/ipfs/QmPdvMtgpnMuU68mWhGtzCxnddXJoV96tT9aPcNbQsqPaM/go-ipfs-cmds" bitswap "gx/ipfs/QmUYXFM46WgGs5AScfL4FSZXa9p5nAhddueyM5auAVZGCQ/go-bitswap" decision "gx/ipfs/QmUYXFM46WgGs5AScfL4FSZXa9p5nAhddueyM5auAVZGCQ/go-bitswap/decision" peer "gx/ipfs/QmY5Grm8pJdiSSVsYxx4uNRgweY72EmYwuSDbRnbFok3iY/go-libp2p-peer" + cmds "gx/ipfs/QmaAP56JAwdjwisPTu4yx17whcjTr6y5JCSCF77Y1rahWV/go-ipfs-cmds" cidutil "gx/ipfs/QmbfKu17LbMWyGUxHEUns9Wf5Dkm8PT6be4uPhTkk4YvaV/go-cidutil" cmdkit "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit" ) diff --git a/core/commands/block.go b/core/commands/block.go index 5e822f60e2d..14262671234 100644 --- a/core/commands/block.go +++ b/core/commands/block.go @@ -11,7 +11,7 @@ import ( coreiface "github.com/ipfs/go-ipfs/core/coreapi/interface" "github.com/ipfs/go-ipfs/core/coreapi/interface/options" - cmds "gx/ipfs/QmPdvMtgpnMuU68mWhGtzCxnddXJoV96tT9aPcNbQsqPaM/go-ipfs-cmds" + cmds "gx/ipfs/QmaAP56JAwdjwisPTu4yx17whcjTr6y5JCSCF77Y1rahWV/go-ipfs-cmds" cmdkit "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit" mh "gx/ipfs/QmerPMzPk1mJVowm8KgmoknWa4yCYvvugMPsgWmDNUvDLW/go-multihash" ) diff --git a/core/commands/bootstrap.go b/core/commands/bootstrap.go index 4a1f97fbfb7..cb7cc426e0b 100644 --- a/core/commands/bootstrap.go +++ b/core/commands/bootstrap.go @@ -9,8 +9,8 @@ import ( repo "github.com/ipfs/go-ipfs/repo" fsrepo "github.com/ipfs/go-ipfs/repo/fsrepo" - cmds "gx/ipfs/QmPdvMtgpnMuU68mWhGtzCxnddXJoV96tT9aPcNbQsqPaM/go-ipfs-cmds" config "gx/ipfs/QmYyzmMnhNTtoXx5ttgUaRdHHckYnQWjPL98hgLAR2QLDD/go-ipfs-config" + cmds "gx/ipfs/QmaAP56JAwdjwisPTu4yx17whcjTr6y5JCSCF77Y1rahWV/go-ipfs-cmds" cmdkit "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit" ) diff --git a/core/commands/cat.go b/core/commands/cat.go index d34e4c7f2d0..3fa2fec09c9 100644 --- a/core/commands/cat.go +++ b/core/commands/cat.go @@ -9,7 +9,7 @@ import ( "github.com/ipfs/go-ipfs/core/commands/cmdenv" "github.com/ipfs/go-ipfs/core/coreapi/interface" - cmds "gx/ipfs/QmPdvMtgpnMuU68mWhGtzCxnddXJoV96tT9aPcNbQsqPaM/go-ipfs-cmds" + cmds "gx/ipfs/QmaAP56JAwdjwisPTu4yx17whcjTr6y5JCSCF77Y1rahWV/go-ipfs-cmds" "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit" ) diff --git a/core/commands/cid.go b/core/commands/cid.go index 82b684a6702..00e912ce2e1 100644 --- a/core/commands/cid.go +++ b/core/commands/cid.go @@ -7,9 +7,9 @@ import ( "strings" "unicode" - cmds "gx/ipfs/QmPdvMtgpnMuU68mWhGtzCxnddXJoV96tT9aPcNbQsqPaM/go-ipfs-cmds" cid "gx/ipfs/QmR8BauakNcBa3RbE4nbQu76PDiJgoQgz8AJdhJuiU4TAw/go-cid" verifcid "gx/ipfs/QmYMQuypUbgsdNHmuCBSUJV6wdQVsBHRivNAp3efHJwZJD/go-verifcid" + cmds "gx/ipfs/QmaAP56JAwdjwisPTu4yx17whcjTr6y5JCSCF77Y1rahWV/go-ipfs-cmds" cidutil "gx/ipfs/QmbfKu17LbMWyGUxHEUns9Wf5Dkm8PT6be4uPhTkk4YvaV/go-cidutil" cmdkit "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit" mbase "gx/ipfs/QmekxXDhCxCJRNuzmHreuaT3BsuJcsjcXWNrtV9C8DRHtd/go-multibase" diff --git a/core/commands/cmdenv/env.go b/core/commands/cmdenv/env.go index 32701442d39..c30cd13f88d 100644 --- a/core/commands/cmdenv/env.go +++ b/core/commands/cmdenv/env.go @@ -7,8 +7,8 @@ import ( "github.com/ipfs/go-ipfs/core" coreiface "github.com/ipfs/go-ipfs/core/coreapi/interface" - cmds "gx/ipfs/QmPdvMtgpnMuU68mWhGtzCxnddXJoV96tT9aPcNbQsqPaM/go-ipfs-cmds" config "gx/ipfs/QmYyzmMnhNTtoXx5ttgUaRdHHckYnQWjPL98hgLAR2QLDD/go-ipfs-config" + cmds "gx/ipfs/QmaAP56JAwdjwisPTu4yx17whcjTr6y5JCSCF77Y1rahWV/go-ipfs-cmds" ) // GetNode extracts the node from the environment. diff --git a/core/commands/commands.go b/core/commands/commands.go index 763d350b287..25015d90a15 100644 --- a/core/commands/commands.go +++ b/core/commands/commands.go @@ -14,7 +14,7 @@ import ( e "github.com/ipfs/go-ipfs/core/commands/e" - cmds "gx/ipfs/QmPdvMtgpnMuU68mWhGtzCxnddXJoV96tT9aPcNbQsqPaM/go-ipfs-cmds" + cmds "gx/ipfs/QmaAP56JAwdjwisPTu4yx17whcjTr6y5JCSCF77Y1rahWV/go-ipfs-cmds" "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit" ) diff --git a/core/commands/commands_test.go b/core/commands/commands_test.go index 75bafd77807..d691eb343b1 100644 --- a/core/commands/commands_test.go +++ b/core/commands/commands_test.go @@ -4,7 +4,7 @@ import ( "strings" "testing" - cmds "gx/ipfs/QmPdvMtgpnMuU68mWhGtzCxnddXJoV96tT9aPcNbQsqPaM/go-ipfs-cmds" + cmds "gx/ipfs/QmaAP56JAwdjwisPTu4yx17whcjTr6y5JCSCF77Y1rahWV/go-ipfs-cmds" ) func collectPaths(prefix string, cmd *cmds.Command, out map[string]struct{}) { diff --git a/core/commands/config.go b/core/commands/config.go index 50dd1ddf34c..45f9308402f 100644 --- a/core/commands/config.go +++ b/core/commands/config.go @@ -15,8 +15,8 @@ import ( fsrepo "github.com/ipfs/go-ipfs/repo/fsrepo" "gx/ipfs/QmP2i47tnU23ijdshrZtuvrSkQPtf9HhsMb9fwGVe8owj2/jsondiff" - cmds "gx/ipfs/QmPdvMtgpnMuU68mWhGtzCxnddXJoV96tT9aPcNbQsqPaM/go-ipfs-cmds" config "gx/ipfs/QmYyzmMnhNTtoXx5ttgUaRdHHckYnQWjPL98hgLAR2QLDD/go-ipfs-config" + cmds "gx/ipfs/QmaAP56JAwdjwisPTu4yx17whcjTr6y5JCSCF77Y1rahWV/go-ipfs-cmds" cmdkit "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit" ) diff --git a/core/commands/dag/dag.go b/core/commands/dag/dag.go index 0af38d418a0..e9bed7ad777 100644 --- a/core/commands/dag/dag.go +++ b/core/commands/dag/dag.go @@ -9,9 +9,9 @@ import ( "github.com/ipfs/go-ipfs/core/coredag" "github.com/ipfs/go-ipfs/pin" - cmds "gx/ipfs/QmPdvMtgpnMuU68mWhGtzCxnddXJoV96tT9aPcNbQsqPaM/go-ipfs-cmds" cid "gx/ipfs/QmR8BauakNcBa3RbE4nbQu76PDiJgoQgz8AJdhJuiU4TAw/go-cid" path "gx/ipfs/QmZErC2Ay6WuGi96CPg316PwitdwgLo6RxZRqVjJjRj2MR/go-path" + cmds "gx/ipfs/QmaAP56JAwdjwisPTu4yx17whcjTr6y5JCSCF77Y1rahWV/go-ipfs-cmds" ipld "gx/ipfs/QmcKKBwfz6FyQdHR2jsXrrF6XeSBXYL86anmWNewpFpoF5/go-ipld-format" cmdkit "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit" mh "gx/ipfs/QmerPMzPk1mJVowm8KgmoknWa4yCYvvugMPsgWmDNUvDLW/go-multihash" diff --git a/core/commands/dht.go b/core/commands/dht.go index c4a3682045f..f4f8ed19b7c 100644 --- a/core/commands/dht.go +++ b/core/commands/dht.go @@ -9,7 +9,6 @@ import ( cmdenv "github.com/ipfs/go-ipfs/core/commands/cmdenv" - cmds "gx/ipfs/QmPdvMtgpnMuU68mWhGtzCxnddXJoV96tT9aPcNbQsqPaM/go-ipfs-cmds" cid "gx/ipfs/QmR8BauakNcBa3RbE4nbQu76PDiJgoQgz8AJdhJuiU4TAw/go-cid" routing "gx/ipfs/QmRASJXJUFygM5qU4YrH7k7jD6S4Hg8nJmgqJ4bYJvLatd/go-libp2p-routing" notif "gx/ipfs/QmRASJXJUFygM5qU4YrH7k7jD6S4Hg8nJmgqJ4bYJvLatd/go-libp2p-routing/notifications" @@ -17,6 +16,7 @@ import ( peer "gx/ipfs/QmY5Grm8pJdiSSVsYxx4uNRgweY72EmYwuSDbRnbFok3iY/go-libp2p-peer" pstore "gx/ipfs/QmZ9zH2FnLcxv1xyzFeUpDUeo55xEhZQHgveZijcxr7TLj/go-libp2p-peerstore" path "gx/ipfs/QmZErC2Ay6WuGi96CPg316PwitdwgLo6RxZRqVjJjRj2MR/go-path" + cmds "gx/ipfs/QmaAP56JAwdjwisPTu4yx17whcjTr6y5JCSCF77Y1rahWV/go-ipfs-cmds" ipld "gx/ipfs/QmcKKBwfz6FyQdHR2jsXrrF6XeSBXYL86anmWNewpFpoF5/go-ipld-format" dag "gx/ipfs/QmdV35UHnL1FM52baPkeUo6u7Fxm2CRUkPTLRPxeF8a4Ap/go-merkledag" cmdkit "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit" diff --git a/core/commands/diag.go b/core/commands/diag.go index f886f7502eb..214cd79b2aa 100644 --- a/core/commands/diag.go +++ b/core/commands/diag.go @@ -1,7 +1,7 @@ package commands import ( - cmds "gx/ipfs/QmPdvMtgpnMuU68mWhGtzCxnddXJoV96tT9aPcNbQsqPaM/go-ipfs-cmds" + cmds "gx/ipfs/QmaAP56JAwdjwisPTu4yx17whcjTr6y5JCSCF77Y1rahWV/go-ipfs-cmds" cmdkit "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit" ) diff --git a/core/commands/dns.go b/core/commands/dns.go index 5ce382b556f..2c99768e404 100644 --- a/core/commands/dns.go +++ b/core/commands/dns.go @@ -8,7 +8,7 @@ import ( namesys "github.com/ipfs/go-ipfs/namesys" nsopts "github.com/ipfs/go-ipfs/namesys/opts" - cmds "gx/ipfs/QmPdvMtgpnMuU68mWhGtzCxnddXJoV96tT9aPcNbQsqPaM/go-ipfs-cmds" + cmds "gx/ipfs/QmaAP56JAwdjwisPTu4yx17whcjTr6y5JCSCF77Y1rahWV/go-ipfs-cmds" cmdkit "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit" ) diff --git a/core/commands/external.go b/core/commands/external.go index 71edeb00d43..a2c33a47bcc 100644 --- a/core/commands/external.go +++ b/core/commands/external.go @@ -10,7 +10,7 @@ import ( commands "github.com/ipfs/go-ipfs/commands" - cmds "gx/ipfs/QmPdvMtgpnMuU68mWhGtzCxnddXJoV96tT9aPcNbQsqPaM/go-ipfs-cmds" + cmds "gx/ipfs/QmaAP56JAwdjwisPTu4yx17whcjTr6y5JCSCF77Y1rahWV/go-ipfs-cmds" cmdkit "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit" ) diff --git a/core/commands/files.go b/core/commands/files.go index 36358b109ef..d262ee213fe 100644 --- a/core/commands/files.go +++ b/core/commands/files.go @@ -15,15 +15,15 @@ import ( iface "github.com/ipfs/go-ipfs/core/coreapi/interface" humanize "gx/ipfs/QmPSBJL4momYnE7DcUyk2DVhD6rH488ZmHBGLbxNdhU44K/go-humanize" - cmds "gx/ipfs/QmPdvMtgpnMuU68mWhGtzCxnddXJoV96tT9aPcNbQsqPaM/go-ipfs-cmds" bservice "gx/ipfs/QmPoh3SrQzFBWtdGK6qmHDV4EanKR6kYPj4DD3J2NLoEmZ/go-blockservice" cid "gx/ipfs/QmR8BauakNcBa3RbE4nbQu76PDiJgoQgz8AJdhJuiU4TAw/go-cid" + mfs "gx/ipfs/QmU3iDRUrxyTYdV2j5MuWLFvP1k7w98vD66PLnNChgvUmZ/go-mfs" offline "gx/ipfs/QmYZwey1thDTynSrvd6qQkX24UpTka6TFhQ2v569UpoqxD/go-ipfs-exchange-offline" - mfs "gx/ipfs/QmYnp3EVZqLjzm8NYigcB3aHqDLFmAVUvtaUdYb3nFDtK6/go-mfs" + cmds "gx/ipfs/QmaAP56JAwdjwisPTu4yx17whcjTr6y5JCSCF77Y1rahWV/go-ipfs-cmds" + ft "gx/ipfs/Qmbvw7kpSM2p6rbQ57WGRhhqNfCiNGW6EKH4xgHLw4bsnB/go-unixfs" ipld "gx/ipfs/QmcKKBwfz6FyQdHR2jsXrrF6XeSBXYL86anmWNewpFpoF5/go-ipld-format" logging "gx/ipfs/QmcuXC5cxs79ro2cUuHs4HQ2bkDLJUYokwL8aivcX6HW3C/go-log" dag "gx/ipfs/QmdV35UHnL1FM52baPkeUo6u7Fxm2CRUkPTLRPxeF8a4Ap/go-merkledag" - ft "gx/ipfs/QmdYvDbHp7qAhZ7GsCj6e1cMo55ND6y2mjWVzwdvcv4f12/go-unixfs" cmdkit "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit" mh "gx/ipfs/QmerPMzPk1mJVowm8KgmoknWa4yCYvvugMPsgWmDNUvDLW/go-multihash" ) diff --git a/core/commands/filestore.go b/core/commands/filestore.go index 666681a0b93..68e7a6095a0 100644 --- a/core/commands/filestore.go +++ b/core/commands/filestore.go @@ -10,8 +10,8 @@ import ( e "github.com/ipfs/go-ipfs/core/commands/e" filestore "github.com/ipfs/go-ipfs/filestore" - cmds "gx/ipfs/QmPdvMtgpnMuU68mWhGtzCxnddXJoV96tT9aPcNbQsqPaM/go-ipfs-cmds" cid "gx/ipfs/QmR8BauakNcBa3RbE4nbQu76PDiJgoQgz8AJdhJuiU4TAw/go-cid" + cmds "gx/ipfs/QmaAP56JAwdjwisPTu4yx17whcjTr6y5JCSCF77Y1rahWV/go-ipfs-cmds" "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit" ) diff --git a/core/commands/get.go b/core/commands/get.go index bdb8765955f..9121e5a41e2 100644 --- a/core/commands/get.go +++ b/core/commands/get.go @@ -13,12 +13,12 @@ import ( cmdenv "github.com/ipfs/go-ipfs/core/commands/cmdenv" e "github.com/ipfs/go-ipfs/core/commands/e" - "gx/ipfs/QmPdvMtgpnMuU68mWhGtzCxnddXJoV96tT9aPcNbQsqPaM/go-ipfs-cmds" "gx/ipfs/QmPtj12fdwuAqj9sBSTNUxBNu8kCGNp8b3o8yUzMm5GHpq/pb" tar "gx/ipfs/QmQine7gvHncNevKtG9QXxf3nXcwSj6aDDmMm52mHofEEp/tar-utils" path "gx/ipfs/QmZErC2Ay6WuGi96CPg316PwitdwgLo6RxZRqVjJjRj2MR/go-path" + "gx/ipfs/QmaAP56JAwdjwisPTu4yx17whcjTr6y5JCSCF77Y1rahWV/go-ipfs-cmds" + uarchive "gx/ipfs/Qmbvw7kpSM2p6rbQ57WGRhhqNfCiNGW6EKH4xgHLw4bsnB/go-unixfs/archive" dag "gx/ipfs/QmdV35UHnL1FM52baPkeUo6u7Fxm2CRUkPTLRPxeF8a4Ap/go-merkledag" - uarchive "gx/ipfs/QmdYvDbHp7qAhZ7GsCj6e1cMo55ND6y2mjWVzwdvcv4f12/go-unixfs/archive" "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit" ) diff --git a/core/commands/get_test.go b/core/commands/get_test.go index 6d0ff4f349d..e67195bf13e 100644 --- a/core/commands/get_test.go +++ b/core/commands/get_test.go @@ -5,7 +5,7 @@ import ( "fmt" "testing" - cmds "gx/ipfs/QmPdvMtgpnMuU68mWhGtzCxnddXJoV96tT9aPcNbQsqPaM/go-ipfs-cmds" + cmds "gx/ipfs/QmaAP56JAwdjwisPTu4yx17whcjTr6y5JCSCF77Y1rahWV/go-ipfs-cmds" cmdkit "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit" ) diff --git a/core/commands/helptext_test.go b/core/commands/helptext_test.go index 63ea3225aca..818f3d9c9fd 100644 --- a/core/commands/helptext_test.go +++ b/core/commands/helptext_test.go @@ -4,7 +4,7 @@ import ( "strings" "testing" - cmds "gx/ipfs/QmPdvMtgpnMuU68mWhGtzCxnddXJoV96tT9aPcNbQsqPaM/go-ipfs-cmds" + cmds "gx/ipfs/QmaAP56JAwdjwisPTu4yx17whcjTr6y5JCSCF77Y1rahWV/go-ipfs-cmds" ) func checkHelptextRecursive(t *testing.T, name []string, c *cmds.Command) { diff --git a/core/commands/id.go b/core/commands/id.go index a8f8995ac78..6ff5d20c7bc 100644 --- a/core/commands/id.go +++ b/core/commands/id.go @@ -12,11 +12,11 @@ import ( cmdenv "github.com/ipfs/go-ipfs/core/commands/cmdenv" ic "gx/ipfs/QmNiJiXwWE3kRhZrC5ej3kSjWHm337pYfhjLGSCDNKJP2s/go-libp2p-crypto" - cmds "gx/ipfs/QmPdvMtgpnMuU68mWhGtzCxnddXJoV96tT9aPcNbQsqPaM/go-ipfs-cmds" identify "gx/ipfs/QmRBaUEQEeFWywfrZJ64QgsmvcqgLSK3VbvGMR2NM2Edpf/go-libp2p/p2p/protocol/identify" kb "gx/ipfs/QmTS16dBXwdQJ67cGf1Z5DV4qZf94vSjBvJbDp158XpwhG/go-libp2p-kbucket" "gx/ipfs/QmY5Grm8pJdiSSVsYxx4uNRgweY72EmYwuSDbRnbFok3iY/go-libp2p-peer" pstore "gx/ipfs/QmZ9zH2FnLcxv1xyzFeUpDUeo55xEhZQHgveZijcxr7TLj/go-libp2p-peerstore" + cmds "gx/ipfs/QmaAP56JAwdjwisPTu4yx17whcjTr6y5JCSCF77Y1rahWV/go-ipfs-cmds" "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit" ) diff --git a/core/commands/keystore.go b/core/commands/keystore.go index d04f28c635b..2a8ecc81a76 100644 --- a/core/commands/keystore.go +++ b/core/commands/keystore.go @@ -8,7 +8,7 @@ import ( cmdenv "github.com/ipfs/go-ipfs/core/commands/cmdenv" options "github.com/ipfs/go-ipfs/core/coreapi/interface/options" - cmds "gx/ipfs/QmPdvMtgpnMuU68mWhGtzCxnddXJoV96tT9aPcNbQsqPaM/go-ipfs-cmds" + cmds "gx/ipfs/QmaAP56JAwdjwisPTu4yx17whcjTr6y5JCSCF77Y1rahWV/go-ipfs-cmds" cmdkit "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit" ) diff --git a/core/commands/log.go b/core/commands/log.go index 3562fba612f..2cdd971579e 100644 --- a/core/commands/log.go +++ b/core/commands/log.go @@ -4,7 +4,7 @@ import ( "fmt" "io" - cmds "gx/ipfs/QmPdvMtgpnMuU68mWhGtzCxnddXJoV96tT9aPcNbQsqPaM/go-ipfs-cmds" + cmds "gx/ipfs/QmaAP56JAwdjwisPTu4yx17whcjTr6y5JCSCF77Y1rahWV/go-ipfs-cmds" logging "gx/ipfs/QmcuXC5cxs79ro2cUuHs4HQ2bkDLJUYokwL8aivcX6HW3C/go-log" lwriter "gx/ipfs/QmcuXC5cxs79ro2cUuHs4HQ2bkDLJUYokwL8aivcX6HW3C/go-log/writer" cmdkit "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit" diff --git a/core/commands/ls.go b/core/commands/ls.go index 8ed84c54d92..09009eee23f 100644 --- a/core/commands/ls.go +++ b/core/commands/ls.go @@ -9,15 +9,15 @@ import ( cmdenv "github.com/ipfs/go-ipfs/core/commands/cmdenv" iface "github.com/ipfs/go-ipfs/core/coreapi/interface" - cmds "gx/ipfs/QmPdvMtgpnMuU68mWhGtzCxnddXJoV96tT9aPcNbQsqPaM/go-ipfs-cmds" blockservice "gx/ipfs/QmPoh3SrQzFBWtdGK6qmHDV4EanKR6kYPj4DD3J2NLoEmZ/go-blockservice" cid "gx/ipfs/QmR8BauakNcBa3RbE4nbQu76PDiJgoQgz8AJdhJuiU4TAw/go-cid" offline "gx/ipfs/QmYZwey1thDTynSrvd6qQkX24UpTka6TFhQ2v569UpoqxD/go-ipfs-exchange-offline" + cmds "gx/ipfs/QmaAP56JAwdjwisPTu4yx17whcjTr6y5JCSCF77Y1rahWV/go-ipfs-cmds" + unixfs "gx/ipfs/Qmbvw7kpSM2p6rbQ57WGRhhqNfCiNGW6EKH4xgHLw4bsnB/go-unixfs" + uio "gx/ipfs/Qmbvw7kpSM2p6rbQ57WGRhhqNfCiNGW6EKH4xgHLw4bsnB/go-unixfs/io" + unixfspb "gx/ipfs/Qmbvw7kpSM2p6rbQ57WGRhhqNfCiNGW6EKH4xgHLw4bsnB/go-unixfs/pb" ipld "gx/ipfs/QmcKKBwfz6FyQdHR2jsXrrF6XeSBXYL86anmWNewpFpoF5/go-ipld-format" merkledag "gx/ipfs/QmdV35UHnL1FM52baPkeUo6u7Fxm2CRUkPTLRPxeF8a4Ap/go-merkledag" - unixfs "gx/ipfs/QmdYvDbHp7qAhZ7GsCj6e1cMo55ND6y2mjWVzwdvcv4f12/go-unixfs" - uio "gx/ipfs/QmdYvDbHp7qAhZ7GsCj6e1cMo55ND6y2mjWVzwdvcv4f12/go-unixfs/io" - unixfspb "gx/ipfs/QmdYvDbHp7qAhZ7GsCj6e1cMo55ND6y2mjWVzwdvcv4f12/go-unixfs/pb" "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit" ) diff --git a/core/commands/mount_nofuse.go b/core/commands/mount_nofuse.go index 58f6f9f6825..561430adf0d 100644 --- a/core/commands/mount_nofuse.go +++ b/core/commands/mount_nofuse.go @@ -3,7 +3,7 @@ package commands import ( - cmds "gx/ipfs/QmPdvMtgpnMuU68mWhGtzCxnddXJoV96tT9aPcNbQsqPaM/go-ipfs-cmds" + cmds "gx/ipfs/QmaAP56JAwdjwisPTu4yx17whcjTr6y5JCSCF77Y1rahWV/go-ipfs-cmds" cmdkit "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit" ) diff --git a/core/commands/mount_unix.go b/core/commands/mount_unix.go index a8785796bbd..d26978f2e71 100644 --- a/core/commands/mount_unix.go +++ b/core/commands/mount_unix.go @@ -9,8 +9,8 @@ import ( cmdenv "github.com/ipfs/go-ipfs/core/commands/cmdenv" nodeMount "github.com/ipfs/go-ipfs/fuse/node" - cmds "gx/ipfs/QmPdvMtgpnMuU68mWhGtzCxnddXJoV96tT9aPcNbQsqPaM/go-ipfs-cmds" config "gx/ipfs/QmYyzmMnhNTtoXx5ttgUaRdHHckYnQWjPL98hgLAR2QLDD/go-ipfs-config" + cmds "gx/ipfs/QmaAP56JAwdjwisPTu4yx17whcjTr6y5JCSCF77Y1rahWV/go-ipfs-cmds" cmdkit "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit" ) diff --git a/core/commands/mount_windows.go b/core/commands/mount_windows.go index 0f1580918eb..6f9abe8eddc 100644 --- a/core/commands/mount_windows.go +++ b/core/commands/mount_windows.go @@ -3,7 +3,7 @@ package commands import ( "errors" - cmds "gx/ipfs/QmPdvMtgpnMuU68mWhGtzCxnddXJoV96tT9aPcNbQsqPaM/go-ipfs-cmds" + cmds "gx/ipfs/QmaAP56JAwdjwisPTu4yx17whcjTr6y5JCSCF77Y1rahWV/go-ipfs-cmds" cmdkit "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit" ) diff --git a/core/commands/name/ipns.go b/core/commands/name/ipns.go index 61e0d703b84..6187419df90 100644 --- a/core/commands/name/ipns.go +++ b/core/commands/name/ipns.go @@ -11,8 +11,8 @@ import ( options "github.com/ipfs/go-ipfs/core/coreapi/interface/options" nsopts "github.com/ipfs/go-ipfs/namesys/opts" - cmds "gx/ipfs/QmPdvMtgpnMuU68mWhGtzCxnddXJoV96tT9aPcNbQsqPaM/go-ipfs-cmds" path "gx/ipfs/QmZErC2Ay6WuGi96CPg316PwitdwgLo6RxZRqVjJjRj2MR/go-path" + cmds "gx/ipfs/QmaAP56JAwdjwisPTu4yx17whcjTr6y5JCSCF77Y1rahWV/go-ipfs-cmds" logging "gx/ipfs/QmcuXC5cxs79ro2cUuHs4HQ2bkDLJUYokwL8aivcX6HW3C/go-log" cmdkit "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit" ) diff --git a/core/commands/name/ipnsps.go b/core/commands/name/ipnsps.go index 3affd399438..e13a0e41795 100644 --- a/core/commands/name/ipnsps.go +++ b/core/commands/name/ipnsps.go @@ -6,8 +6,8 @@ import ( "strings" "github.com/ipfs/go-ipfs/core/commands/cmdenv" - "gx/ipfs/QmPdvMtgpnMuU68mWhGtzCxnddXJoV96tT9aPcNbQsqPaM/go-ipfs-cmds" "gx/ipfs/QmY5Grm8pJdiSSVsYxx4uNRgweY72EmYwuSDbRnbFok3iY/go-libp2p-peer" + "gx/ipfs/QmaAP56JAwdjwisPTu4yx17whcjTr6y5JCSCF77Y1rahWV/go-ipfs-cmds" "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit" "gx/ipfs/QmfARXVCzpwFXQdepAJZuqyNDgV9doEsMnVCo1ssmuSe1U/go-libp2p-record" ) diff --git a/core/commands/name/name.go b/core/commands/name/name.go index 5d224545992..964e7a6914b 100644 --- a/core/commands/name/name.go +++ b/core/commands/name/name.go @@ -1,7 +1,7 @@ package name import ( - "gx/ipfs/QmPdvMtgpnMuU68mWhGtzCxnddXJoV96tT9aPcNbQsqPaM/go-ipfs-cmds" + "gx/ipfs/QmaAP56JAwdjwisPTu4yx17whcjTr6y5JCSCF77Y1rahWV/go-ipfs-cmds" "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit" ) diff --git a/core/commands/name/publish.go b/core/commands/name/publish.go index 5e590ec3786..7d083b2455f 100644 --- a/core/commands/name/publish.go +++ b/core/commands/name/publish.go @@ -10,7 +10,7 @@ import ( iface "github.com/ipfs/go-ipfs/core/coreapi/interface" options "github.com/ipfs/go-ipfs/core/coreapi/interface/options" - cmds "gx/ipfs/QmPdvMtgpnMuU68mWhGtzCxnddXJoV96tT9aPcNbQsqPaM/go-ipfs-cmds" + cmds "gx/ipfs/QmaAP56JAwdjwisPTu4yx17whcjTr6y5JCSCF77Y1rahWV/go-ipfs-cmds" cmdkit "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit" ) diff --git a/core/commands/object/diff.go b/core/commands/object/diff.go index edc3ad96666..b37b3375de8 100644 --- a/core/commands/object/diff.go +++ b/core/commands/object/diff.go @@ -8,7 +8,7 @@ import ( coreiface "github.com/ipfs/go-ipfs/core/coreapi/interface" "github.com/ipfs/go-ipfs/dagutils" - cmds "gx/ipfs/QmPdvMtgpnMuU68mWhGtzCxnddXJoV96tT9aPcNbQsqPaM/go-ipfs-cmds" + cmds "gx/ipfs/QmaAP56JAwdjwisPTu4yx17whcjTr6y5JCSCF77Y1rahWV/go-ipfs-cmds" cmdkit "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit" ) diff --git a/core/commands/object/object.go b/core/commands/object/object.go index 3ae69cbd725..0843c4e2f14 100644 --- a/core/commands/object/object.go +++ b/core/commands/object/object.go @@ -12,8 +12,8 @@ import ( coreiface "github.com/ipfs/go-ipfs/core/coreapi/interface" "github.com/ipfs/go-ipfs/core/coreapi/interface/options" - cmds "gx/ipfs/QmPdvMtgpnMuU68mWhGtzCxnddXJoV96tT9aPcNbQsqPaM/go-ipfs-cmds" cid "gx/ipfs/QmR8BauakNcBa3RbE4nbQu76PDiJgoQgz8AJdhJuiU4TAw/go-cid" + cmds "gx/ipfs/QmaAP56JAwdjwisPTu4yx17whcjTr6y5JCSCF77Y1rahWV/go-ipfs-cmds" ipld "gx/ipfs/QmcKKBwfz6FyQdHR2jsXrrF6XeSBXYL86anmWNewpFpoF5/go-ipld-format" dag "gx/ipfs/QmdV35UHnL1FM52baPkeUo6u7Fxm2CRUkPTLRPxeF8a4Ap/go-merkledag" cmdkit "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit" diff --git a/core/commands/object/patch.go b/core/commands/object/patch.go index f4f81eb02dd..aa022db5a52 100644 --- a/core/commands/object/patch.go +++ b/core/commands/object/patch.go @@ -8,7 +8,7 @@ import ( coreiface "github.com/ipfs/go-ipfs/core/coreapi/interface" "github.com/ipfs/go-ipfs/core/coreapi/interface/options" - cmds "gx/ipfs/QmPdvMtgpnMuU68mWhGtzCxnddXJoV96tT9aPcNbQsqPaM/go-ipfs-cmds" + cmds "gx/ipfs/QmaAP56JAwdjwisPTu4yx17whcjTr6y5JCSCF77Y1rahWV/go-ipfs-cmds" cmdkit "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit" ) diff --git a/core/commands/p2p.go b/core/commands/p2p.go index dcfe83a0636..9de026aee41 100644 --- a/core/commands/p2p.go +++ b/core/commands/p2p.go @@ -14,12 +14,12 @@ import ( cmdenv "github.com/ipfs/go-ipfs/core/commands/cmdenv" p2p "github.com/ipfs/go-ipfs/p2p" - cmds "gx/ipfs/QmPdvMtgpnMuU68mWhGtzCxnddXJoV96tT9aPcNbQsqPaM/go-ipfs-cmds" ma "gx/ipfs/QmRKLtwMw131aK7ugC3G7ybpumMz78YrJe5dzneyindvG1/go-multiaddr" ipfsaddr "gx/ipfs/QmSzEdVLaPMQGAKKGo4mKjsbWcfz6w8CoDjhRPxdk7xYdn/go-ipfs-addr" madns "gx/ipfs/QmT4zgnKCyZBpRyxzsvZqUjzUkMWLJ2pZCw7uk6M6Kto5m/go-multiaddr-dns" pstore "gx/ipfs/QmZ9zH2FnLcxv1xyzFeUpDUeo55xEhZQHgveZijcxr7TLj/go-libp2p-peerstore" protocol "gx/ipfs/QmZNkThpqfVXs9GNbexPrfBbXSLNYeKrE7jwFM2oqHbyqN/go-libp2p-protocol" + cmds "gx/ipfs/QmaAP56JAwdjwisPTu4yx17whcjTr6y5JCSCF77Y1rahWV/go-ipfs-cmds" cmdkit "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit" ) diff --git a/core/commands/pin.go b/core/commands/pin.go index 14d2e07838a..c7be82a8e51 100644 --- a/core/commands/pin.go +++ b/core/commands/pin.go @@ -15,11 +15,11 @@ import ( corerepo "github.com/ipfs/go-ipfs/core/corerepo" pin "github.com/ipfs/go-ipfs/pin" - cmds "gx/ipfs/QmPdvMtgpnMuU68mWhGtzCxnddXJoV96tT9aPcNbQsqPaM/go-ipfs-cmds" bserv "gx/ipfs/QmPoh3SrQzFBWtdGK6qmHDV4EanKR6kYPj4DD3J2NLoEmZ/go-blockservice" cid "gx/ipfs/QmR8BauakNcBa3RbE4nbQu76PDiJgoQgz8AJdhJuiU4TAw/go-cid" "gx/ipfs/QmYMQuypUbgsdNHmuCBSUJV6wdQVsBHRivNAp3efHJwZJD/go-verifcid" offline "gx/ipfs/QmYZwey1thDTynSrvd6qQkX24UpTka6TFhQ2v569UpoqxD/go-ipfs-exchange-offline" + cmds "gx/ipfs/QmaAP56JAwdjwisPTu4yx17whcjTr6y5JCSCF77Y1rahWV/go-ipfs-cmds" dag "gx/ipfs/QmdV35UHnL1FM52baPkeUo6u7Fxm2CRUkPTLRPxeF8a4Ap/go-merkledag" cmdkit "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit" ) diff --git a/core/commands/ping.go b/core/commands/ping.go index d610094e189..55af0be64c9 100644 --- a/core/commands/ping.go +++ b/core/commands/ping.go @@ -10,12 +10,12 @@ import ( "github.com/ipfs/go-ipfs/core/commands/cmdenv" - cmds "gx/ipfs/QmPdvMtgpnMuU68mWhGtzCxnddXJoV96tT9aPcNbQsqPaM/go-ipfs-cmds" ping "gx/ipfs/QmRBaUEQEeFWywfrZJ64QgsmvcqgLSK3VbvGMR2NM2Edpf/go-libp2p/p2p/protocol/ping" ma "gx/ipfs/QmRKLtwMw131aK7ugC3G7ybpumMz78YrJe5dzneyindvG1/go-multiaddr" iaddr "gx/ipfs/QmSzEdVLaPMQGAKKGo4mKjsbWcfz6w8CoDjhRPxdk7xYdn/go-ipfs-addr" "gx/ipfs/QmY5Grm8pJdiSSVsYxx4uNRgweY72EmYwuSDbRnbFok3iY/go-libp2p-peer" pstore "gx/ipfs/QmZ9zH2FnLcxv1xyzFeUpDUeo55xEhZQHgveZijcxr7TLj/go-libp2p-peerstore" + cmds "gx/ipfs/QmaAP56JAwdjwisPTu4yx17whcjTr6y5JCSCF77Y1rahWV/go-ipfs-cmds" cmdkit "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit" ) diff --git a/core/commands/pubsub.go b/core/commands/pubsub.go index 61ba6379d7c..a69a6ec82c6 100644 --- a/core/commands/pubsub.go +++ b/core/commands/pubsub.go @@ -11,7 +11,7 @@ import ( cmdenv "github.com/ipfs/go-ipfs/core/commands/cmdenv" options "github.com/ipfs/go-ipfs/core/coreapi/interface/options" - cmds "gx/ipfs/QmPdvMtgpnMuU68mWhGtzCxnddXJoV96tT9aPcNbQsqPaM/go-ipfs-cmds" + cmds "gx/ipfs/QmaAP56JAwdjwisPTu4yx17whcjTr6y5JCSCF77Y1rahWV/go-ipfs-cmds" cmdkit "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit" ) diff --git a/core/commands/refs.go b/core/commands/refs.go index 45ccd86ad0a..c0a0ffebaf7 100644 --- a/core/commands/refs.go +++ b/core/commands/refs.go @@ -10,9 +10,9 @@ import ( core "github.com/ipfs/go-ipfs/core" cmdenv "github.com/ipfs/go-ipfs/core/commands/cmdenv" - cmds "gx/ipfs/QmPdvMtgpnMuU68mWhGtzCxnddXJoV96tT9aPcNbQsqPaM/go-ipfs-cmds" cid "gx/ipfs/QmR8BauakNcBa3RbE4nbQu76PDiJgoQgz8AJdhJuiU4TAw/go-cid" path "gx/ipfs/QmZErC2Ay6WuGi96CPg316PwitdwgLo6RxZRqVjJjRj2MR/go-path" + cmds "gx/ipfs/QmaAP56JAwdjwisPTu4yx17whcjTr6y5JCSCF77Y1rahWV/go-ipfs-cmds" ipld "gx/ipfs/QmcKKBwfz6FyQdHR2jsXrrF6XeSBXYL86anmWNewpFpoF5/go-ipld-format" cmdkit "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit" ) diff --git a/core/commands/repo.go b/core/commands/repo.go index a56b65d9aab..0067c79a00f 100644 --- a/core/commands/repo.go +++ b/core/commands/repo.go @@ -16,10 +16,10 @@ import ( corerepo "github.com/ipfs/go-ipfs/core/corerepo" fsrepo "github.com/ipfs/go-ipfs/repo/fsrepo" - cmds "gx/ipfs/QmPdvMtgpnMuU68mWhGtzCxnddXJoV96tT9aPcNbQsqPaM/go-ipfs-cmds" cid "gx/ipfs/QmR8BauakNcBa3RbE4nbQu76PDiJgoQgz8AJdhJuiU4TAw/go-cid" bstore "gx/ipfs/QmS2aqUZLJp8kF1ihE5rvDGE5LvmKDPnx32w9Z1BW9xLV5/go-ipfs-blockstore" config "gx/ipfs/QmYyzmMnhNTtoXx5ttgUaRdHHckYnQWjPL98hgLAR2QLDD/go-ipfs-config" + cmds "gx/ipfs/QmaAP56JAwdjwisPTu4yx17whcjTr6y5JCSCF77Y1rahWV/go-ipfs-cmds" cmdkit "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit" ) diff --git a/core/commands/resolve.go b/core/commands/resolve.go index 48f75a0f324..61b8269414e 100644 --- a/core/commands/resolve.go +++ b/core/commands/resolve.go @@ -15,7 +15,7 @@ import ( nsopts "github.com/ipfs/go-ipfs/namesys/opts" path "gx/ipfs/QmZErC2Ay6WuGi96CPg316PwitdwgLo6RxZRqVjJjRj2MR/go-path" - cmds "gx/ipfs/QmPdvMtgpnMuU68mWhGtzCxnddXJoV96tT9aPcNbQsqPaM/go-ipfs-cmds" + cmds "gx/ipfs/QmaAP56JAwdjwisPTu4yx17whcjTr6y5JCSCF77Y1rahWV/go-ipfs-cmds" cmdkit "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit" ) diff --git a/core/commands/root.go b/core/commands/root.go index d61d728cf7d..ce9fdafa1bf 100644 --- a/core/commands/root.go +++ b/core/commands/root.go @@ -8,7 +8,7 @@ import ( ocmd "github.com/ipfs/go-ipfs/core/commands/object" unixfs "github.com/ipfs/go-ipfs/core/commands/unixfs" - cmds "gx/ipfs/QmPdvMtgpnMuU68mWhGtzCxnddXJoV96tT9aPcNbQsqPaM/go-ipfs-cmds" + cmds "gx/ipfs/QmaAP56JAwdjwisPTu4yx17whcjTr6y5JCSCF77Y1rahWV/go-ipfs-cmds" logging "gx/ipfs/QmcuXC5cxs79ro2cUuHs4HQ2bkDLJUYokwL8aivcX6HW3C/go-log" "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit" ) diff --git a/core/commands/shutdown.go b/core/commands/shutdown.go index d1300bcf899..affbc68d513 100644 --- a/core/commands/shutdown.go +++ b/core/commands/shutdown.go @@ -3,7 +3,7 @@ package commands import ( cmdenv "github.com/ipfs/go-ipfs/core/commands/cmdenv" - cmds "gx/ipfs/QmPdvMtgpnMuU68mWhGtzCxnddXJoV96tT9aPcNbQsqPaM/go-ipfs-cmds" + cmds "gx/ipfs/QmaAP56JAwdjwisPTu4yx17whcjTr6y5JCSCF77Y1rahWV/go-ipfs-cmds" "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit" ) diff --git a/core/commands/stat.go b/core/commands/stat.go index c28f2d57c1a..1777561a5b7 100644 --- a/core/commands/stat.go +++ b/core/commands/stat.go @@ -9,9 +9,9 @@ import ( cmdenv "github.com/ipfs/go-ipfs/core/commands/cmdenv" humanize "gx/ipfs/QmPSBJL4momYnE7DcUyk2DVhD6rH488ZmHBGLbxNdhU44K/go-humanize" - cmds "gx/ipfs/QmPdvMtgpnMuU68mWhGtzCxnddXJoV96tT9aPcNbQsqPaM/go-ipfs-cmds" peer "gx/ipfs/QmY5Grm8pJdiSSVsYxx4uNRgweY72EmYwuSDbRnbFok3iY/go-libp2p-peer" protocol "gx/ipfs/QmZNkThpqfVXs9GNbexPrfBbXSLNYeKrE7jwFM2oqHbyqN/go-libp2p-protocol" + cmds "gx/ipfs/QmaAP56JAwdjwisPTu4yx17whcjTr6y5JCSCF77Y1rahWV/go-ipfs-cmds" metrics "gx/ipfs/QmbYN6UmTJn5UUQdi5CTsU86TXVBSrTcRk5UmyA36Qx2J6/go-libp2p-metrics" cmdkit "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit" ) diff --git a/core/commands/swarm.go b/core/commands/swarm.go index 54d75ded2d3..3c25855ef7d 100644 --- a/core/commands/swarm.go +++ b/core/commands/swarm.go @@ -12,7 +12,6 @@ import ( repo "github.com/ipfs/go-ipfs/repo" fsrepo "github.com/ipfs/go-ipfs/repo/fsrepo" - cmds "gx/ipfs/QmPdvMtgpnMuU68mWhGtzCxnddXJoV96tT9aPcNbQsqPaM/go-ipfs-cmds" inet "gx/ipfs/QmPtFaR7BWHLAjSwLh9kXcyrgTzDpuhcWLkx8ioa9RMYnx/go-libp2p-net" swarm "gx/ipfs/QmQdLXW5JTSsrVb3ZpnpbASRwyM8CcE4XcM5nPbN19dWLr/go-libp2p-swarm" ma "gx/ipfs/QmRKLtwMw131aK7ugC3G7ybpumMz78YrJe5dzneyindvG1/go-multiaddr" @@ -21,6 +20,7 @@ import ( peer "gx/ipfs/QmY5Grm8pJdiSSVsYxx4uNRgweY72EmYwuSDbRnbFok3iY/go-libp2p-peer" config "gx/ipfs/QmYyzmMnhNTtoXx5ttgUaRdHHckYnQWjPL98hgLAR2QLDD/go-ipfs-config" pstore "gx/ipfs/QmZ9zH2FnLcxv1xyzFeUpDUeo55xEhZQHgveZijcxr7TLj/go-libp2p-peerstore" + cmds "gx/ipfs/QmaAP56JAwdjwisPTu4yx17whcjTr6y5JCSCF77Y1rahWV/go-ipfs-cmds" cmdkit "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit" ) diff --git a/core/commands/sysdiag.go b/core/commands/sysdiag.go index bf1b7b5c61c..4178e87c8b2 100644 --- a/core/commands/sysdiag.go +++ b/core/commands/sysdiag.go @@ -8,9 +8,9 @@ import ( version "github.com/ipfs/go-ipfs" cmdenv "github.com/ipfs/go-ipfs/core/commands/cmdenv" - cmds "gx/ipfs/QmPdvMtgpnMuU68mWhGtzCxnddXJoV96tT9aPcNbQsqPaM/go-ipfs-cmds" manet "gx/ipfs/QmQVUtnrNGtCRkCMpXgpApfzQjc8FDaDVxHqWH8cnZQeh5/go-multiaddr-net" sysi "gx/ipfs/QmZRjKbHa6DenStpQJFiaPcEwkZqrx7TH6xTf342LDU3qM/go-sysinfo" + cmds "gx/ipfs/QmaAP56JAwdjwisPTu4yx17whcjTr6y5JCSCF77Y1rahWV/go-ipfs-cmds" cmdkit "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit" ) diff --git a/core/commands/tar.go b/core/commands/tar.go index ca7f8eef606..2a98494e27f 100644 --- a/core/commands/tar.go +++ b/core/commands/tar.go @@ -9,8 +9,8 @@ import ( coreiface "github.com/ipfs/go-ipfs/core/coreapi/interface" tar "github.com/ipfs/go-ipfs/tar" - cmds "gx/ipfs/QmPdvMtgpnMuU68mWhGtzCxnddXJoV96tT9aPcNbQsqPaM/go-ipfs-cmds" "gx/ipfs/QmZErC2Ay6WuGi96CPg316PwitdwgLo6RxZRqVjJjRj2MR/go-path" + cmds "gx/ipfs/QmaAP56JAwdjwisPTu4yx17whcjTr6y5JCSCF77Y1rahWV/go-ipfs-cmds" dag "gx/ipfs/QmdV35UHnL1FM52baPkeUo6u7Fxm2CRUkPTLRPxeF8a4Ap/go-merkledag" cmdkit "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit" ) diff --git a/core/commands/unixfs/ls.go b/core/commands/unixfs/ls.go index 142b8cb1a2f..b7090c68821 100644 --- a/core/commands/unixfs/ls.go +++ b/core/commands/unixfs/ls.go @@ -9,9 +9,9 @@ import ( cmdenv "github.com/ipfs/go-ipfs/core/commands/cmdenv" iface "github.com/ipfs/go-ipfs/core/coreapi/interface" - cmds "gx/ipfs/QmPdvMtgpnMuU68mWhGtzCxnddXJoV96tT9aPcNbQsqPaM/go-ipfs-cmds" + cmds "gx/ipfs/QmaAP56JAwdjwisPTu4yx17whcjTr6y5JCSCF77Y1rahWV/go-ipfs-cmds" + unixfs "gx/ipfs/Qmbvw7kpSM2p6rbQ57WGRhhqNfCiNGW6EKH4xgHLw4bsnB/go-unixfs" merkledag "gx/ipfs/QmdV35UHnL1FM52baPkeUo6u7Fxm2CRUkPTLRPxeF8a4Ap/go-merkledag" - unixfs "gx/ipfs/QmdYvDbHp7qAhZ7GsCj6e1cMo55ND6y2mjWVzwdvcv4f12/go-unixfs" cmdkit "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit" ) diff --git a/core/commands/unixfs/unixfs.go b/core/commands/unixfs/unixfs.go index 79ff4dc26f1..6d74fbaf88b 100644 --- a/core/commands/unixfs/unixfs.go +++ b/core/commands/unixfs/unixfs.go @@ -1,7 +1,7 @@ package unixfs import ( - cmds "gx/ipfs/QmPdvMtgpnMuU68mWhGtzCxnddXJoV96tT9aPcNbQsqPaM/go-ipfs-cmds" + cmds "gx/ipfs/QmaAP56JAwdjwisPTu4yx17whcjTr6y5JCSCF77Y1rahWV/go-ipfs-cmds" cmdkit "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit" ) diff --git a/core/commands/urlstore.go b/core/commands/urlstore.go index 104f56244e0..c634357307f 100644 --- a/core/commands/urlstore.go +++ b/core/commands/urlstore.go @@ -9,12 +9,12 @@ import ( filestore "github.com/ipfs/go-ipfs/filestore" pin "github.com/ipfs/go-ipfs/pin" - cmds "gx/ipfs/QmPdvMtgpnMuU68mWhGtzCxnddXJoV96tT9aPcNbQsqPaM/go-ipfs-cmds" chunk "gx/ipfs/QmR4QQVkBZsZENRjYFVi8dEtPL3daZRNKk24m4r6WKJHNm/go-ipfs-chunker" cid "gx/ipfs/QmR8BauakNcBa3RbE4nbQu76PDiJgoQgz8AJdhJuiU4TAw/go-cid" - balanced "gx/ipfs/QmdYvDbHp7qAhZ7GsCj6e1cMo55ND6y2mjWVzwdvcv4f12/go-unixfs/importer/balanced" - ihelper "gx/ipfs/QmdYvDbHp7qAhZ7GsCj6e1cMo55ND6y2mjWVzwdvcv4f12/go-unixfs/importer/helpers" - trickle "gx/ipfs/QmdYvDbHp7qAhZ7GsCj6e1cMo55ND6y2mjWVzwdvcv4f12/go-unixfs/importer/trickle" + cmds "gx/ipfs/QmaAP56JAwdjwisPTu4yx17whcjTr6y5JCSCF77Y1rahWV/go-ipfs-cmds" + balanced "gx/ipfs/Qmbvw7kpSM2p6rbQ57WGRhhqNfCiNGW6EKH4xgHLw4bsnB/go-unixfs/importer/balanced" + ihelper "gx/ipfs/Qmbvw7kpSM2p6rbQ57WGRhhqNfCiNGW6EKH4xgHLw4bsnB/go-unixfs/importer/helpers" + trickle "gx/ipfs/Qmbvw7kpSM2p6rbQ57WGRhhqNfCiNGW6EKH4xgHLw4bsnB/go-unixfs/importer/trickle" cmdkit "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit" mh "gx/ipfs/QmerPMzPk1mJVowm8KgmoknWa4yCYvvugMPsgWmDNUvDLW/go-multihash" ) diff --git a/core/commands/version.go b/core/commands/version.go index 3fb49e871ca..7218c03bd0c 100644 --- a/core/commands/version.go +++ b/core/commands/version.go @@ -8,7 +8,7 @@ import ( version "github.com/ipfs/go-ipfs" fsrepo "github.com/ipfs/go-ipfs/repo/fsrepo" - cmds "gx/ipfs/QmPdvMtgpnMuU68mWhGtzCxnddXJoV96tT9aPcNbQsqPaM/go-ipfs-cmds" + cmds "gx/ipfs/QmaAP56JAwdjwisPTu4yx17whcjTr6y5JCSCF77Y1rahWV/go-ipfs-cmds" "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit" ) diff --git a/core/core.go b/core/core.go index b0f44054f8c..6a146bb20c9 100644 --- a/core/core.go +++ b/core/core.go @@ -50,6 +50,7 @@ import ( goprocess "gx/ipfs/QmSF8fPo3jgVBAy8fpdjjYqgG87dkJgUprRBHRd2tmfgpP/goprocess" mamask "gx/ipfs/QmSMZwvs3n4GBikZ7hKzT17c3bk65FmyZo2JqtJ16swqCv/multiaddr-filter" quic "gx/ipfs/QmSvK3DvgynMo45orM88RQowdupvgdxs3fDyahQsKkmcUP/go-libp2p-quic-transport" + mfs "gx/ipfs/QmU3iDRUrxyTYdV2j5MuWLFvP1k7w98vD66PLnNChgvUmZ/go-mfs" bitswap "gx/ipfs/QmUYXFM46WgGs5AScfL4FSZXa9p5nAhddueyM5auAVZGCQ/go-bitswap" bsnet "gx/ipfs/QmUYXFM46WgGs5AScfL4FSZXa9p5nAhddueyM5auAVZGCQ/go-bitswap/network" connmgr "gx/ipfs/QmWJBngogUPF87Xz788NotnwfYS1B5oanKew82zuMwUkQu/go-libp2p-connmgr" @@ -59,18 +60,17 @@ import ( pnet "gx/ipfs/QmY4Q5JC4vxLEi8EpVxJM4rcRryEVtH1zRKVTAm6BKV1pg/go-libp2p-pnet" peer "gx/ipfs/QmY5Grm8pJdiSSVsYxx4uNRgweY72EmYwuSDbRnbFok3iY/go-libp2p-peer" smux "gx/ipfs/QmY9JXR3FupnYAYJWK9aMr9bCpqWKcToQ1tz8DVGTrHpHw/go-stream-muxer" - mfs "gx/ipfs/QmYnp3EVZqLjzm8NYigcB3aHqDLFmAVUvtaUdYb3nFDtK6/go-mfs" config "gx/ipfs/QmYyzmMnhNTtoXx5ttgUaRdHHckYnQWjPL98hgLAR2QLDD/go-ipfs-config" pstore "gx/ipfs/QmZ9zH2FnLcxv1xyzFeUpDUeo55xEhZQHgveZijcxr7TLj/go-libp2p-peerstore" resolver "gx/ipfs/QmZErC2Ay6WuGi96CPg316PwitdwgLo6RxZRqVjJjRj2MR/go-path/resolver" mplex "gx/ipfs/QmZsejKNkeFSQe5TcmYXJ8iq6qPL1FpsP4eAA8j7RfE7xg/go-smux-multiplex" pubsub "gx/ipfs/QmaqGyUhWLsJbVo1QAujSu13mxNjFJ98Kt2VWGSnShGE1Q/go-libp2p-pubsub" metrics "gx/ipfs/QmbYN6UmTJn5UUQdi5CTsU86TXVBSrTcRk5UmyA36Qx2J6/go-libp2p-metrics" + ft "gx/ipfs/Qmbvw7kpSM2p6rbQ57WGRhhqNfCiNGW6EKH4xgHLw4bsnB/go-unixfs" ipld "gx/ipfs/QmcKKBwfz6FyQdHR2jsXrrF6XeSBXYL86anmWNewpFpoF5/go-ipld-format" logging "gx/ipfs/QmcuXC5cxs79ro2cUuHs4HQ2bkDLJUYokwL8aivcX6HW3C/go-log" autonat "gx/ipfs/QmdFdMoDmvuEJYsAKRA2BMobzNaeunmc16DqPxdHHfQ25K/go-libp2p-autonat-svc" merkledag "gx/ipfs/QmdV35UHnL1FM52baPkeUo6u7Fxm2CRUkPTLRPxeF8a4Ap/go-merkledag" - ft "gx/ipfs/QmdYvDbHp7qAhZ7GsCj6e1cMo55ND6y2mjWVzwdvcv4f12/go-unixfs" nilrouting "gx/ipfs/QmdmWkx54g7VfVyxeG8ic84uf4G6Eq1GohuyKA3XDuJ8oC/go-ipfs-routing/none" yamux "gx/ipfs/Qmdps3CYh5htGQSrPvzg5PHouVexLmtpbuLCqc4vuej8PC/go-smux-yamux" ds "gx/ipfs/Qmf4xQhNomPNhrtZc67qSnfJSjxjXs9LWvknJtSXwimPrM/go-datastore" diff --git a/core/coreapi/interface/unixfs.go b/core/coreapi/interface/unixfs.go index 002635d9936..3a214085c2a 100644 --- a/core/coreapi/interface/unixfs.go +++ b/core/coreapi/interface/unixfs.go @@ -6,7 +6,7 @@ import ( options "github.com/ipfs/go-ipfs/core/coreapi/interface/options" - files "gx/ipfs/QmZMWMvWMVKCbHetJ4RgndbuEF1io2UpUxwQwtNjtYPzSC/go-ipfs-files" + files "gx/ipfs/QmXWZCd8jfaHmt4UDSnjKmGcrQMw95bDGWqEeVLVJjoANX/go-ipfs-files" ipld "gx/ipfs/QmcKKBwfz6FyQdHR2jsXrrF6XeSBXYL86anmWNewpFpoF5/go-ipld-format" ) diff --git a/core/coreapi/name_test.go b/core/coreapi/name_test.go index eee63cf8aa0..1b64508f50b 100644 --- a/core/coreapi/name_test.go +++ b/core/coreapi/name_test.go @@ -10,8 +10,8 @@ import ( "testing" "time" + files "gx/ipfs/QmXWZCd8jfaHmt4UDSnjKmGcrQMw95bDGWqEeVLVJjoANX/go-ipfs-files" ipath "gx/ipfs/QmZErC2Ay6WuGi96CPg316PwitdwgLo6RxZRqVjJjRj2MR/go-path" - files "gx/ipfs/QmZMWMvWMVKCbHetJ4RgndbuEF1io2UpUxwQwtNjtYPzSC/go-ipfs-files" coreiface "github.com/ipfs/go-ipfs/core/coreapi/interface" opt "github.com/ipfs/go-ipfs/core/coreapi/interface/options" diff --git a/core/coreapi/object.go b/core/coreapi/object.go index a1e05b1e0e7..9e18d479bf6 100644 --- a/core/coreapi/object.go +++ b/core/coreapi/object.go @@ -17,9 +17,9 @@ import ( "github.com/ipfs/go-ipfs/pin" cid "gx/ipfs/QmR8BauakNcBa3RbE4nbQu76PDiJgoQgz8AJdhJuiU4TAw/go-cid" + ft "gx/ipfs/Qmbvw7kpSM2p6rbQ57WGRhhqNfCiNGW6EKH4xgHLw4bsnB/go-unixfs" ipld "gx/ipfs/QmcKKBwfz6FyQdHR2jsXrrF6XeSBXYL86anmWNewpFpoF5/go-ipld-format" dag "gx/ipfs/QmdV35UHnL1FM52baPkeUo6u7Fxm2CRUkPTLRPxeF8a4Ap/go-merkledag" - ft "gx/ipfs/QmdYvDbHp7qAhZ7GsCj6e1cMo55ND6y2mjWVzwdvcv4f12/go-unixfs" ) const inputLimit = 2 << 20 diff --git a/core/coreapi/path.go b/core/coreapi/path.go index 83f1d83848a..93d39cd1eae 100644 --- a/core/coreapi/path.go +++ b/core/coreapi/path.go @@ -11,8 +11,8 @@ import ( "gx/ipfs/QmR8BauakNcBa3RbE4nbQu76PDiJgoQgz8AJdhJuiU4TAw/go-cid" ipfspath "gx/ipfs/QmZErC2Ay6WuGi96CPg316PwitdwgLo6RxZRqVjJjRj2MR/go-path" "gx/ipfs/QmZErC2Ay6WuGi96CPg316PwitdwgLo6RxZRqVjJjRj2MR/go-path/resolver" + uio "gx/ipfs/Qmbvw7kpSM2p6rbQ57WGRhhqNfCiNGW6EKH4xgHLw4bsnB/go-unixfs/io" ipld "gx/ipfs/QmcKKBwfz6FyQdHR2jsXrrF6XeSBXYL86anmWNewpFpoF5/go-ipld-format" - uio "gx/ipfs/QmdYvDbHp7qAhZ7GsCj6e1cMo55ND6y2mjWVzwdvcv4f12/go-unixfs/io" ) // ResolveNode resolves the path `p` using Unixfs resolver, gets and returns the diff --git a/core/coreapi/unixfile.go b/core/coreapi/unixfile.go index 7e63a495b6d..1ff44e3bfa3 100644 --- a/core/coreapi/unixfile.go +++ b/core/coreapi/unixfile.go @@ -10,11 +10,11 @@ import ( "github.com/ipfs/go-ipfs/core/coreapi/interface" - files "gx/ipfs/QmZMWMvWMVKCbHetJ4RgndbuEF1io2UpUxwQwtNjtYPzSC/go-ipfs-files" + files "gx/ipfs/QmXWZCd8jfaHmt4UDSnjKmGcrQMw95bDGWqEeVLVJjoANX/go-ipfs-files" + ft "gx/ipfs/Qmbvw7kpSM2p6rbQ57WGRhhqNfCiNGW6EKH4xgHLw4bsnB/go-unixfs" + uio "gx/ipfs/Qmbvw7kpSM2p6rbQ57WGRhhqNfCiNGW6EKH4xgHLw4bsnB/go-unixfs/io" ipld "gx/ipfs/QmcKKBwfz6FyQdHR2jsXrrF6XeSBXYL86anmWNewpFpoF5/go-ipld-format" dag "gx/ipfs/QmdV35UHnL1FM52baPkeUo6u7Fxm2CRUkPTLRPxeF8a4Ap/go-merkledag" - ft "gx/ipfs/QmdYvDbHp7qAhZ7GsCj6e1cMo55ND6y2mjWVzwdvcv4f12/go-unixfs" - uio "gx/ipfs/QmdYvDbHp7qAhZ7GsCj6e1cMo55ND6y2mjWVzwdvcv4f12/go-unixfs/io" ) // Number to file to prefetch in directories diff --git a/core/coreapi/unixfs.go b/core/coreapi/unixfs.go index 9c8efcb49c3..4f129d6e012 100644 --- a/core/coreapi/unixfs.go +++ b/core/coreapi/unixfs.go @@ -13,15 +13,15 @@ import ( blockservice "gx/ipfs/QmPoh3SrQzFBWtdGK6qmHDV4EanKR6kYPj4DD3J2NLoEmZ/go-blockservice" bstore "gx/ipfs/QmS2aqUZLJp8kF1ihE5rvDGE5LvmKDPnx32w9Z1BW9xLV5/go-ipfs-blockstore" + mfs "gx/ipfs/QmU3iDRUrxyTYdV2j5MuWLFvP1k7w98vD66PLnNChgvUmZ/go-mfs" + files "gx/ipfs/QmXWZCd8jfaHmt4UDSnjKmGcrQMw95bDGWqEeVLVJjoANX/go-ipfs-files" offline "gx/ipfs/QmYZwey1thDTynSrvd6qQkX24UpTka6TFhQ2v569UpoqxD/go-ipfs-exchange-offline" - mfs "gx/ipfs/QmYnp3EVZqLjzm8NYigcB3aHqDLFmAVUvtaUdYb3nFDtK6/go-mfs" - files "gx/ipfs/QmZMWMvWMVKCbHetJ4RgndbuEF1io2UpUxwQwtNjtYPzSC/go-ipfs-files" cidutil "gx/ipfs/QmbfKu17LbMWyGUxHEUns9Wf5Dkm8PT6be4uPhTkk4YvaV/go-cidutil" + ft "gx/ipfs/Qmbvw7kpSM2p6rbQ57WGRhhqNfCiNGW6EKH4xgHLw4bsnB/go-unixfs" + uio "gx/ipfs/Qmbvw7kpSM2p6rbQ57WGRhhqNfCiNGW6EKH4xgHLw4bsnB/go-unixfs/io" ipld "gx/ipfs/QmcKKBwfz6FyQdHR2jsXrrF6XeSBXYL86anmWNewpFpoF5/go-ipld-format" dag "gx/ipfs/QmdV35UHnL1FM52baPkeUo6u7Fxm2CRUkPTLRPxeF8a4Ap/go-merkledag" dagtest "gx/ipfs/QmdV35UHnL1FM52baPkeUo6u7Fxm2CRUkPTLRPxeF8a4Ap/go-merkledag/test" - ft "gx/ipfs/QmdYvDbHp7qAhZ7GsCj6e1cMo55ND6y2mjWVzwdvcv4f12/go-unixfs" - uio "gx/ipfs/QmdYvDbHp7qAhZ7GsCj6e1cMo55ND6y2mjWVzwdvcv4f12/go-unixfs/io" ) type UnixfsAPI CoreAPI diff --git a/core/coreapi/unixfs_test.go b/core/coreapi/unixfs_test.go index 722a0b30fd5..228c04a0501 100644 --- a/core/coreapi/unixfs_test.go +++ b/core/coreapi/unixfs_test.go @@ -26,12 +26,12 @@ import ( ci "gx/ipfs/QmNiJiXwWE3kRhZrC5ej3kSjWHm337pYfhjLGSCDNKJP2s/go-libp2p-crypto" mocknet "gx/ipfs/QmRBaUEQEeFWywfrZJ64QgsmvcqgLSK3VbvGMR2NM2Edpf/go-libp2p/p2p/net/mock" cbor "gx/ipfs/QmRoARq3nkUb13HSKZGepCZSWe5GrVPwx7xURJGZ7KWv9V/go-ipld-cbor" + files "gx/ipfs/QmXWZCd8jfaHmt4UDSnjKmGcrQMw95bDGWqEeVLVJjoANX/go-ipfs-files" peer "gx/ipfs/QmY5Grm8pJdiSSVsYxx4uNRgweY72EmYwuSDbRnbFok3iY/go-libp2p-peer" config "gx/ipfs/QmYyzmMnhNTtoXx5ttgUaRdHHckYnQWjPL98hgLAR2QLDD/go-ipfs-config" pstore "gx/ipfs/QmZ9zH2FnLcxv1xyzFeUpDUeo55xEhZQHgveZijcxr7TLj/go-libp2p-peerstore" - files "gx/ipfs/QmZMWMvWMVKCbHetJ4RgndbuEF1io2UpUxwQwtNjtYPzSC/go-ipfs-files" + unixfs "gx/ipfs/Qmbvw7kpSM2p6rbQ57WGRhhqNfCiNGW6EKH4xgHLw4bsnB/go-unixfs" mdag "gx/ipfs/QmdV35UHnL1FM52baPkeUo6u7Fxm2CRUkPTLRPxeF8a4Ap/go-merkledag" - unixfs "gx/ipfs/QmdYvDbHp7qAhZ7GsCj6e1cMo55ND6y2mjWVzwdvcv4f12/go-unixfs" mh "gx/ipfs/QmerPMzPk1mJVowm8KgmoknWa4yCYvvugMPsgWmDNUvDLW/go-multihash" datastore "gx/ipfs/Qmf4xQhNomPNhrtZc67qSnfJSjxjXs9LWvknJtSXwimPrM/go-datastore" syncds "gx/ipfs/Qmf4xQhNomPNhrtZc67qSnfJSjxjXs9LWvknJtSXwimPrM/go-datastore/sync" diff --git a/core/corehttp/commands.go b/core/corehttp/commands.go index c51417293f6..73b38d4f73e 100644 --- a/core/corehttp/commands.go +++ b/core/corehttp/commands.go @@ -14,10 +14,10 @@ import ( "github.com/ipfs/go-ipfs/core" corecommands "github.com/ipfs/go-ipfs/core/commands" - cmds "gx/ipfs/QmPdvMtgpnMuU68mWhGtzCxnddXJoV96tT9aPcNbQsqPaM/go-ipfs-cmds" - cmdsHttp "gx/ipfs/QmPdvMtgpnMuU68mWhGtzCxnddXJoV96tT9aPcNbQsqPaM/go-ipfs-cmds/http" config "gx/ipfs/QmYyzmMnhNTtoXx5ttgUaRdHHckYnQWjPL98hgLAR2QLDD/go-ipfs-config" path "gx/ipfs/QmZErC2Ay6WuGi96CPg316PwitdwgLo6RxZRqVjJjRj2MR/go-path" + cmds "gx/ipfs/QmaAP56JAwdjwisPTu4yx17whcjTr6y5JCSCF77Y1rahWV/go-ipfs-cmds" + cmdsHttp "gx/ipfs/QmaAP56JAwdjwisPTu4yx17whcjTr6y5JCSCF77Y1rahWV/go-ipfs-cmds/http" ) var ( diff --git a/core/corehttp/gateway_handler.go b/core/corehttp/gateway_handler.go index 7c6d272aa83..3379689f45f 100644 --- a/core/corehttp/gateway_handler.go +++ b/core/corehttp/gateway_handler.go @@ -22,14 +22,14 @@ import ( chunker "gx/ipfs/QmR4QQVkBZsZENRjYFVi8dEtPL3daZRNKk24m4r6WKJHNm/go-ipfs-chunker" cid "gx/ipfs/QmR8BauakNcBa3RbE4nbQu76PDiJgoQgz8AJdhJuiU4TAw/go-cid" routing "gx/ipfs/QmRASJXJUFygM5qU4YrH7k7jD6S4Hg8nJmgqJ4bYJvLatd/go-libp2p-routing" + files "gx/ipfs/QmXWZCd8jfaHmt4UDSnjKmGcrQMw95bDGWqEeVLVJjoANX/go-ipfs-files" path "gx/ipfs/QmZErC2Ay6WuGi96CPg316PwitdwgLo6RxZRqVjJjRj2MR/go-path" resolver "gx/ipfs/QmZErC2Ay6WuGi96CPg316PwitdwgLo6RxZRqVjJjRj2MR/go-path/resolver" - files "gx/ipfs/QmZMWMvWMVKCbHetJ4RgndbuEF1io2UpUxwQwtNjtYPzSC/go-ipfs-files" + ft "gx/ipfs/Qmbvw7kpSM2p6rbQ57WGRhhqNfCiNGW6EKH4xgHLw4bsnB/go-unixfs" + "gx/ipfs/Qmbvw7kpSM2p6rbQ57WGRhhqNfCiNGW6EKH4xgHLw4bsnB/go-unixfs/importer" + uio "gx/ipfs/Qmbvw7kpSM2p6rbQ57WGRhhqNfCiNGW6EKH4xgHLw4bsnB/go-unixfs/io" ipld "gx/ipfs/QmcKKBwfz6FyQdHR2jsXrrF6XeSBXYL86anmWNewpFpoF5/go-ipld-format" dag "gx/ipfs/QmdV35UHnL1FM52baPkeUo6u7Fxm2CRUkPTLRPxeF8a4Ap/go-merkledag" - ft "gx/ipfs/QmdYvDbHp7qAhZ7GsCj6e1cMo55ND6y2mjWVzwdvcv4f12/go-unixfs" - "gx/ipfs/QmdYvDbHp7qAhZ7GsCj6e1cMo55ND6y2mjWVzwdvcv4f12/go-unixfs/importer" - uio "gx/ipfs/QmdYvDbHp7qAhZ7GsCj6e1cMo55ND6y2mjWVzwdvcv4f12/go-unixfs/io" multibase "gx/ipfs/QmekxXDhCxCJRNuzmHreuaT3BsuJcsjcXWNrtV9C8DRHtd/go-multibase" ) diff --git a/core/corerepo/gc.go b/core/corerepo/gc.go index aae2c0032d0..ca6db969eaf 100644 --- a/core/corerepo/gc.go +++ b/core/corerepo/gc.go @@ -12,7 +12,7 @@ import ( humanize "gx/ipfs/QmPSBJL4momYnE7DcUyk2DVhD6rH488ZmHBGLbxNdhU44K/go-humanize" cid "gx/ipfs/QmR8BauakNcBa3RbE4nbQu76PDiJgoQgz8AJdhJuiU4TAw/go-cid" - mfs "gx/ipfs/QmYnp3EVZqLjzm8NYigcB3aHqDLFmAVUvtaUdYb3nFDtK6/go-mfs" + mfs "gx/ipfs/QmU3iDRUrxyTYdV2j5MuWLFvP1k7w98vD66PLnNChgvUmZ/go-mfs" logging "gx/ipfs/QmcuXC5cxs79ro2cUuHs4HQ2bkDLJUYokwL8aivcX6HW3C/go-log" ) diff --git a/core/coreunix/add.go b/core/coreunix/add.go index 702bb108566..868bd5d7ef7 100644 --- a/core/coreunix/add.go +++ b/core/coreunix/add.go @@ -18,15 +18,15 @@ import ( posinfo "gx/ipfs/QmR6YMs8EkXQLXNwQKxLnQp2VBZSepoEJ8KCZAyanJHhJu/go-ipfs-posinfo" cid "gx/ipfs/QmR8BauakNcBa3RbE4nbQu76PDiJgoQgz8AJdhJuiU4TAw/go-cid" bstore "gx/ipfs/QmS2aqUZLJp8kF1ihE5rvDGE5LvmKDPnx32w9Z1BW9xLV5/go-ipfs-blockstore" - mfs "gx/ipfs/QmYnp3EVZqLjzm8NYigcB3aHqDLFmAVUvtaUdYb3nFDtK6/go-mfs" - files "gx/ipfs/QmZMWMvWMVKCbHetJ4RgndbuEF1io2UpUxwQwtNjtYPzSC/go-ipfs-files" + mfs "gx/ipfs/QmU3iDRUrxyTYdV2j5MuWLFvP1k7w98vD66PLnNChgvUmZ/go-mfs" + files "gx/ipfs/QmXWZCd8jfaHmt4UDSnjKmGcrQMw95bDGWqEeVLVJjoANX/go-ipfs-files" + unixfs "gx/ipfs/Qmbvw7kpSM2p6rbQ57WGRhhqNfCiNGW6EKH4xgHLw4bsnB/go-unixfs" + balanced "gx/ipfs/Qmbvw7kpSM2p6rbQ57WGRhhqNfCiNGW6EKH4xgHLw4bsnB/go-unixfs/importer/balanced" + ihelper "gx/ipfs/Qmbvw7kpSM2p6rbQ57WGRhhqNfCiNGW6EKH4xgHLw4bsnB/go-unixfs/importer/helpers" + trickle "gx/ipfs/Qmbvw7kpSM2p6rbQ57WGRhhqNfCiNGW6EKH4xgHLw4bsnB/go-unixfs/importer/trickle" ipld "gx/ipfs/QmcKKBwfz6FyQdHR2jsXrrF6XeSBXYL86anmWNewpFpoF5/go-ipld-format" logging "gx/ipfs/QmcuXC5cxs79ro2cUuHs4HQ2bkDLJUYokwL8aivcX6HW3C/go-log" dag "gx/ipfs/QmdV35UHnL1FM52baPkeUo6u7Fxm2CRUkPTLRPxeF8a4Ap/go-merkledag" - unixfs "gx/ipfs/QmdYvDbHp7qAhZ7GsCj6e1cMo55ND6y2mjWVzwdvcv4f12/go-unixfs" - balanced "gx/ipfs/QmdYvDbHp7qAhZ7GsCj6e1cMo55ND6y2mjWVzwdvcv4f12/go-unixfs/importer/balanced" - ihelper "gx/ipfs/QmdYvDbHp7qAhZ7GsCj6e1cMo55ND6y2mjWVzwdvcv4f12/go-unixfs/importer/helpers" - trickle "gx/ipfs/QmdYvDbHp7qAhZ7GsCj6e1cMo55ND6y2mjWVzwdvcv4f12/go-unixfs/importer/trickle" ) var log = logging.Logger("coreunix") diff --git a/core/coreunix/add_test.go b/core/coreunix/add_test.go index 69b4a5e16a8..a96a63c1d90 100644 --- a/core/coreunix/add_test.go +++ b/core/coreunix/add_test.go @@ -20,8 +20,8 @@ import ( cid "gx/ipfs/QmR8BauakNcBa3RbE4nbQu76PDiJgoQgz8AJdhJuiU4TAw/go-cid" blockstore "gx/ipfs/QmS2aqUZLJp8kF1ihE5rvDGE5LvmKDPnx32w9Z1BW9xLV5/go-ipfs-blockstore" blocks "gx/ipfs/QmWoXtvgC8inqFkAATB7cp2Dax7XBi9VDvSg9RCCZufmRk/go-block-format" + files "gx/ipfs/QmXWZCd8jfaHmt4UDSnjKmGcrQMw95bDGWqEeVLVJjoANX/go-ipfs-files" config "gx/ipfs/QmYyzmMnhNTtoXx5ttgUaRdHHckYnQWjPL98hgLAR2QLDD/go-ipfs-config" - files "gx/ipfs/QmZMWMvWMVKCbHetJ4RgndbuEF1io2UpUxwQwtNjtYPzSC/go-ipfs-files" dag "gx/ipfs/QmdV35UHnL1FM52baPkeUo6u7Fxm2CRUkPTLRPxeF8a4Ap/go-merkledag" datastore "gx/ipfs/Qmf4xQhNomPNhrtZc67qSnfJSjxjXs9LWvknJtSXwimPrM/go-datastore" syncds "gx/ipfs/Qmf4xQhNomPNhrtZc67qSnfJSjxjXs9LWvknJtSXwimPrM/go-datastore/sync" diff --git a/core/coreunix/metadata.go b/core/coreunix/metadata.go index eb8c2d62da4..03c13a62b84 100644 --- a/core/coreunix/metadata.go +++ b/core/coreunix/metadata.go @@ -3,8 +3,8 @@ package coreunix import ( core "github.com/ipfs/go-ipfs/core" cid "gx/ipfs/QmR8BauakNcBa3RbE4nbQu76PDiJgoQgz8AJdhJuiU4TAw/go-cid" + ft "gx/ipfs/Qmbvw7kpSM2p6rbQ57WGRhhqNfCiNGW6EKH4xgHLw4bsnB/go-unixfs" dag "gx/ipfs/QmdV35UHnL1FM52baPkeUo6u7Fxm2CRUkPTLRPxeF8a4Ap/go-merkledag" - ft "gx/ipfs/QmdYvDbHp7qAhZ7GsCj6e1cMo55ND6y2mjWVzwdvcv4f12/go-unixfs" ) func AddMetadataTo(n *core.IpfsNode, skey string, m *ft.Metadata) (string, error) { diff --git a/core/coreunix/metadata_test.go b/core/coreunix/metadata_test.go index 5cd89ef1a0e..c35a60794fd 100644 --- a/core/coreunix/metadata_test.go +++ b/core/coreunix/metadata_test.go @@ -8,10 +8,10 @@ import ( core "github.com/ipfs/go-ipfs/core" bserv "gx/ipfs/QmPoh3SrQzFBWtdGK6qmHDV4EanKR6kYPj4DD3J2NLoEmZ/go-blockservice" + ft "gx/ipfs/Qmbvw7kpSM2p6rbQ57WGRhhqNfCiNGW6EKH4xgHLw4bsnB/go-unixfs" + importer "gx/ipfs/Qmbvw7kpSM2p6rbQ57WGRhhqNfCiNGW6EKH4xgHLw4bsnB/go-unixfs/importer" + uio "gx/ipfs/Qmbvw7kpSM2p6rbQ57WGRhhqNfCiNGW6EKH4xgHLw4bsnB/go-unixfs/io" merkledag "gx/ipfs/QmdV35UHnL1FM52baPkeUo6u7Fxm2CRUkPTLRPxeF8a4Ap/go-merkledag" - ft "gx/ipfs/QmdYvDbHp7qAhZ7GsCj6e1cMo55ND6y2mjWVzwdvcv4f12/go-unixfs" - importer "gx/ipfs/QmdYvDbHp7qAhZ7GsCj6e1cMo55ND6y2mjWVzwdvcv4f12/go-unixfs/importer" - uio "gx/ipfs/QmdYvDbHp7qAhZ7GsCj6e1cMo55ND6y2mjWVzwdvcv4f12/go-unixfs/io" u "gx/ipfs/QmNohiVssaPw3KVLZik59DBVGTSm2dGvYT9eoXt5DQ36Yz/go-ipfs-util" chunker "gx/ipfs/QmR4QQVkBZsZENRjYFVi8dEtPL3daZRNKk24m4r6WKJHNm/go-ipfs-chunker" diff --git a/fuse/ipns/common.go b/fuse/ipns/common.go index 8783227e48e..c5035eb4285 100644 --- a/fuse/ipns/common.go +++ b/fuse/ipns/common.go @@ -7,7 +7,7 @@ import ( nsys "github.com/ipfs/go-ipfs/namesys" ci "gx/ipfs/QmNiJiXwWE3kRhZrC5ej3kSjWHm337pYfhjLGSCDNKJP2s/go-libp2p-crypto" path "gx/ipfs/QmZErC2Ay6WuGi96CPg316PwitdwgLo6RxZRqVjJjRj2MR/go-path" - ft "gx/ipfs/QmdYvDbHp7qAhZ7GsCj6e1cMo55ND6y2mjWVzwdvcv4f12/go-unixfs" + ft "gx/ipfs/Qmbvw7kpSM2p6rbQ57WGRhhqNfCiNGW6EKH4xgHLw4bsnB/go-unixfs" ) // InitializeKeyspace sets the ipns record for the given key to diff --git a/fuse/ipns/ipns_unix.go b/fuse/ipns/ipns_unix.go index b49b9e8c82a..f59562d6d3c 100644 --- a/fuse/ipns/ipns_unix.go +++ b/fuse/ipns/ipns_unix.go @@ -14,15 +14,15 @@ import ( core "github.com/ipfs/go-ipfs/core" namesys "github.com/ipfs/go-ipfs/namesys" path "gx/ipfs/QmZErC2Ay6WuGi96CPg316PwitdwgLo6RxZRqVjJjRj2MR/go-path" + ft "gx/ipfs/Qmbvw7kpSM2p6rbQ57WGRhhqNfCiNGW6EKH4xgHLw4bsnB/go-unixfs" dag "gx/ipfs/QmdV35UHnL1FM52baPkeUo6u7Fxm2CRUkPTLRPxeF8a4Ap/go-merkledag" - ft "gx/ipfs/QmdYvDbHp7qAhZ7GsCj6e1cMo55ND6y2mjWVzwdvcv4f12/go-unixfs" ci "gx/ipfs/QmNiJiXwWE3kRhZrC5ej3kSjWHm337pYfhjLGSCDNKJP2s/go-libp2p-crypto" cid "gx/ipfs/QmR8BauakNcBa3RbE4nbQu76PDiJgoQgz8AJdhJuiU4TAw/go-cid" fuse "gx/ipfs/QmSJBsmLP1XMjv8hxYg2rUMdPDB7YUpyBo9idjrJ6Cmq6F/fuse" fs "gx/ipfs/QmSJBsmLP1XMjv8hxYg2rUMdPDB7YUpyBo9idjrJ6Cmq6F/fuse/fs" + mfs "gx/ipfs/QmU3iDRUrxyTYdV2j5MuWLFvP1k7w98vD66PLnNChgvUmZ/go-mfs" peer "gx/ipfs/QmY5Grm8pJdiSSVsYxx4uNRgweY72EmYwuSDbRnbFok3iY/go-libp2p-peer" - mfs "gx/ipfs/QmYnp3EVZqLjzm8NYigcB3aHqDLFmAVUvtaUdYb3nFDtK6/go-mfs" logging "gx/ipfs/QmcuXC5cxs79ro2cUuHs4HQ2bkDLJUYokwL8aivcX6HW3C/go-log" ) diff --git a/fuse/readonly/ipfs_test.go b/fuse/readonly/ipfs_test.go index 53e2ba321d8..dea91b65359 100644 --- a/fuse/readonly/ipfs_test.go +++ b/fuse/readonly/ipfs_test.go @@ -22,10 +22,10 @@ import ( ci "gx/ipfs/QmPuhRE325DR8ChNcFtgd6F1eANCHy1oohXZPpYop4xsK6/go-testutil/ci" chunker "gx/ipfs/QmR4QQVkBZsZENRjYFVi8dEtPL3daZRNKk24m4r6WKJHNm/go-ipfs-chunker" fstest "gx/ipfs/QmSJBsmLP1XMjv8hxYg2rUMdPDB7YUpyBo9idjrJ6Cmq6F/fuse/fs/fstestutil" + importer "gx/ipfs/Qmbvw7kpSM2p6rbQ57WGRhhqNfCiNGW6EKH4xgHLw4bsnB/go-unixfs/importer" + uio "gx/ipfs/Qmbvw7kpSM2p6rbQ57WGRhhqNfCiNGW6EKH4xgHLw4bsnB/go-unixfs/io" ipld "gx/ipfs/QmcKKBwfz6FyQdHR2jsXrrF6XeSBXYL86anmWNewpFpoF5/go-ipld-format" dag "gx/ipfs/QmdV35UHnL1FM52baPkeUo6u7Fxm2CRUkPTLRPxeF8a4Ap/go-merkledag" - importer "gx/ipfs/QmdYvDbHp7qAhZ7GsCj6e1cMo55ND6y2mjWVzwdvcv4f12/go-unixfs/importer" - uio "gx/ipfs/QmdYvDbHp7qAhZ7GsCj6e1cMo55ND6y2mjWVzwdvcv4f12/go-unixfs/io" ) func maybeSkipFuseTests(t *testing.T) { diff --git a/fuse/readonly/readonly_unix.go b/fuse/readonly/readonly_unix.go index 8786f4ab54f..51e0cd1587c 100644 --- a/fuse/readonly/readonly_unix.go +++ b/fuse/readonly/readonly_unix.go @@ -12,9 +12,9 @@ import ( core "github.com/ipfs/go-ipfs/core" path "gx/ipfs/QmZErC2Ay6WuGi96CPg316PwitdwgLo6RxZRqVjJjRj2MR/go-path" + ft "gx/ipfs/Qmbvw7kpSM2p6rbQ57WGRhhqNfCiNGW6EKH4xgHLw4bsnB/go-unixfs" + uio "gx/ipfs/Qmbvw7kpSM2p6rbQ57WGRhhqNfCiNGW6EKH4xgHLw4bsnB/go-unixfs/io" mdag "gx/ipfs/QmdV35UHnL1FM52baPkeUo6u7Fxm2CRUkPTLRPxeF8a4Ap/go-merkledag" - ft "gx/ipfs/QmdYvDbHp7qAhZ7GsCj6e1cMo55ND6y2mjWVzwdvcv4f12/go-unixfs" - uio "gx/ipfs/QmdYvDbHp7qAhZ7GsCj6e1cMo55ND6y2mjWVzwdvcv4f12/go-unixfs/io" lgbl "gx/ipfs/QmQSREHX6CMoPkT5FfuA4A9cWSFwoKY8RAzjf5m7Gpdtqu/go-libp2p-loggables" fuse "gx/ipfs/QmSJBsmLP1XMjv8hxYg2rUMdPDB7YUpyBo9idjrJ6Cmq6F/fuse" diff --git a/namesys/namesys_test.go b/namesys/namesys_test.go index e97933afd80..4e398485f73 100644 --- a/namesys/namesys_test.go +++ b/namesys/namesys_test.go @@ -12,7 +12,7 @@ import ( peer "gx/ipfs/QmY5Grm8pJdiSSVsYxx4uNRgweY72EmYwuSDbRnbFok3iY/go-libp2p-peer" pstoremem "gx/ipfs/QmZ9zH2FnLcxv1xyzFeUpDUeo55xEhZQHgveZijcxr7TLj/go-libp2p-peerstore/pstoremem" path "gx/ipfs/QmZErC2Ay6WuGi96CPg316PwitdwgLo6RxZRqVjJjRj2MR/go-path" - "gx/ipfs/QmdYvDbHp7qAhZ7GsCj6e1cMo55ND6y2mjWVzwdvcv4f12/go-unixfs" + "gx/ipfs/Qmbvw7kpSM2p6rbQ57WGRhhqNfCiNGW6EKH4xgHLw4bsnB/go-unixfs" offroute "gx/ipfs/QmdmWkx54g7VfVyxeG8ic84uf4G6Eq1GohuyKA3XDuJ8oC/go-ipfs-routing/offline" ds "gx/ipfs/Qmf4xQhNomPNhrtZc67qSnfJSjxjXs9LWvknJtSXwimPrM/go-datastore" dssync "gx/ipfs/Qmf4xQhNomPNhrtZc67qSnfJSjxjXs9LWvknJtSXwimPrM/go-datastore/sync" diff --git a/namesys/publisher.go b/namesys/publisher.go index 78bfd160f69..64bea671417 100644 --- a/namesys/publisher.go +++ b/namesys/publisher.go @@ -8,7 +8,7 @@ import ( pin "github.com/ipfs/go-ipfs/pin" path "gx/ipfs/QmZErC2Ay6WuGi96CPg316PwitdwgLo6RxZRqVjJjRj2MR/go-path" - ft "gx/ipfs/QmdYvDbHp7qAhZ7GsCj6e1cMo55ND6y2mjWVzwdvcv4f12/go-unixfs" + ft "gx/ipfs/Qmbvw7kpSM2p6rbQ57WGRhhqNfCiNGW6EKH4xgHLw4bsnB/go-unixfs" ci "gx/ipfs/QmNiJiXwWE3kRhZrC5ej3kSjWHm337pYfhjLGSCDNKJP2s/go-libp2p-crypto" ipns "gx/ipfs/QmPrt2JqvtFcgMBmYBjtZ5jFzq6HoFXy8PTwLb2Dpm2cGf/go-ipns" diff --git a/package.json b/package.json index 68500bf98fb..a9c25ba144b 100644 --- a/package.json +++ b/package.json @@ -294,9 +294,9 @@ "version": "3.0.27" }, { - "hash": "QmPdvMtgpnMuU68mWhGtzCxnddXJoV96tT9aPcNbQsqPaM", + "hash": "QmaAP56JAwdjwisPTu4yx17whcjTr6y5JCSCF77Y1rahWV", "name": "go-ipfs-cmds", - "version": "2.0.8" + "version": "2.0.9" }, { "hash": "Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg", @@ -512,9 +512,9 @@ }, { "author": "why", - "hash": "QmdYvDbHp7qAhZ7GsCj6e1cMo55ND6y2mjWVzwdvcv4f12", + "hash": "Qmbvw7kpSM2p6rbQ57WGRhhqNfCiNGW6EKH4xgHLw4bsnB", "name": "go-unixfs", - "version": "1.2.9" + "version": "1.2.10" }, { "author": "magik6k", @@ -530,9 +530,9 @@ }, { "author": "hsanjuan", - "hash": "QmYnp3EVZqLjzm8NYigcB3aHqDLFmAVUvtaUdYb3nFDtK6", + "hash": "QmU3iDRUrxyTYdV2j5MuWLFvP1k7w98vD66PLnNChgvUmZ", "name": "go-mfs", - "version": "0.1.27" + "version": "0.1.28" }, { "author": "kevina", @@ -577,9 +577,9 @@ }, { "author": "magik6k", - "hash": "QmZMWMvWMVKCbHetJ4RgndbuEF1io2UpUxwQwtNjtYPzSC", + "hash": "QmXWZCd8jfaHmt4UDSnjKmGcrQMw95bDGWqEeVLVJjoANX", "name": "go-ipfs-files", - "version": "1.0.1" + "version": "2.0.3" }, { "author": "whyrusleeping", diff --git a/tar/format.go b/tar/format.go index 0ad437ba83d..d3987646780 100644 --- a/tar/format.go +++ b/tar/format.go @@ -10,9 +10,9 @@ import ( "github.com/ipfs/go-ipfs/dagutils" path "gx/ipfs/QmZErC2Ay6WuGi96CPg316PwitdwgLo6RxZRqVjJjRj2MR/go-path" + importer "gx/ipfs/Qmbvw7kpSM2p6rbQ57WGRhhqNfCiNGW6EKH4xgHLw4bsnB/go-unixfs/importer" + uio "gx/ipfs/Qmbvw7kpSM2p6rbQ57WGRhhqNfCiNGW6EKH4xgHLw4bsnB/go-unixfs/io" dag "gx/ipfs/QmdV35UHnL1FM52baPkeUo6u7Fxm2CRUkPTLRPxeF8a4Ap/go-merkledag" - importer "gx/ipfs/QmdYvDbHp7qAhZ7GsCj6e1cMo55ND6y2mjWVzwdvcv4f12/go-unixfs/importer" - uio "gx/ipfs/QmdYvDbHp7qAhZ7GsCj6e1cMo55ND6y2mjWVzwdvcv4f12/go-unixfs/io" chunker "gx/ipfs/QmR4QQVkBZsZENRjYFVi8dEtPL3daZRNKk24m4r6WKJHNm/go-ipfs-chunker" ipld "gx/ipfs/QmcKKBwfz6FyQdHR2jsXrrF6XeSBXYL86anmWNewpFpoF5/go-ipld-format" From ce952a56414a288207b1ce0d79deafe90c2d77f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Fri, 26 Oct 2018 15:56:30 +0200 Subject: [PATCH 02/16] files2.0: fix build errors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit License: MIT Signed-off-by: Łukasz Magiera --- cmd/ipfs/init.go | 2 +- core/commands/add.go | 31 +++--- core/commands/block.go | 2 +- core/commands/dag/dag.go | 2 +- core/commands/files.go | 2 +- core/commands/object/object.go | 2 +- core/commands/object/patch.go | 4 +- core/commands/tar.go | 5 +- core/coreapi/interface/unixfs.go | 10 +- core/coreapi/name_test.go | 2 +- core/coreapi/unixfile.go | 89 ++--------------- core/coreapi/unixfs.go | 4 +- core/coreapi/unixfs_test.go | 158 ++++++++++++++++--------------- core/corehttp/gateway_handler.go | 2 +- core/coreunix/add.go | 50 +++++----- core/coreunix/add_test.go | 14 ++- 16 files changed, 156 insertions(+), 223 deletions(-) diff --git a/cmd/ipfs/init.go b/cmd/ipfs/init.go index fa25eb5d743..9d4bb51a418 100644 --- a/cmd/ipfs/init.go +++ b/cmd/ipfs/init.go @@ -85,7 +85,7 @@ environment variable: f := req.Files if f != nil { - confFile, err := f.NextFile() + _, confFile, err := f.NextFile() if err != nil { return err } diff --git a/core/commands/add.go b/core/commands/add.go index d78bad32398..0585193225d 100644 --- a/core/commands/add.go +++ b/core/commands/add.go @@ -6,9 +6,9 @@ import ( "os" "strings" - cmdenv "github.com/ipfs/go-ipfs/core/commands/cmdenv" + "github.com/ipfs/go-ipfs/core/commands/cmdenv" coreiface "github.com/ipfs/go-ipfs/core/coreapi/interface" - options "github.com/ipfs/go-ipfs/core/coreapi/interface/options" + "github.com/ipfs/go-ipfs/core/coreapi/interface/options" pb "gx/ipfs/QmPtj12fdwuAqj9sBSTNUxBNu8kCGNp8b3o8yUzMm5GHpq/pb" files "gx/ipfs/QmXWZCd8jfaHmt4UDSnjKmGcrQMw95bDGWqEeVLVJjoANX/go-ipfs-files" @@ -226,24 +226,17 @@ You can now check what blocks have been created by: outChan := make(chan interface{}) req := res.Request() - sizeFile, ok := req.Files.(files.SizeFile) - if ok { - // Could be slow. - go func() { - size, err := sizeFile.Size() - if err != nil { - log.Warningf("error getting files size: %s", err) - // see comment above - return - } + // Could be slow. + go func() { + size, err := req.Files.Size() + if err != nil { + log.Warningf("error getting files size: %s", err) + // see comment above + return + } - sizeChan <- size - }() - } else { - // we don't need to error, the progress bar just - // won't know how big the files are - log.Warning("cannot determine size of input file") - } + sizeChan <- size + }() progressBar := func(wait chan struct{}) { defer close(wait) diff --git a/core/commands/block.go b/core/commands/block.go index 14262671234..054e621d80b 100644 --- a/core/commands/block.go +++ b/core/commands/block.go @@ -153,7 +153,7 @@ than 'sha2-256' or format to anything other than 'v0' will result in CIDv1. return err } - file, err := req.Files.NextFile() + _, file, err := req.Files.NextFile() if err != nil { return err } diff --git a/core/commands/dag/dag.go b/core/commands/dag/dag.go index e9bed7ad777..1e3b0441e52 100644 --- a/core/commands/dag/dag.go +++ b/core/commands/dag/dag.go @@ -93,7 +93,7 @@ into an object of the specified format. } for { - file, err := req.Files.NextFile() + _, file, err := req.Files.NextFile() if err == io.EOF { // Finished the list of files. break diff --git a/core/commands/files.go b/core/commands/files.go index d262ee213fe..eeff856a7ce 100644 --- a/core/commands/files.go +++ b/core/commands/files.go @@ -769,7 +769,7 @@ stat' on the file or any of its ancestors. return err } - input, err := req.Files.NextFile() + _, input, err := req.Files.NextFile() if err != nil { return err } diff --git a/core/commands/object/object.go b/core/commands/object/object.go index 0843c4e2f14..bba3abae5b5 100644 --- a/core/commands/object/object.go +++ b/core/commands/object/object.go @@ -391,7 +391,7 @@ And then run: return err } - input, err := req.Files.NextFile() + _, input, err := req.Files.NextFile() if err != nil && err != io.EOF { return err } diff --git a/core/commands/object/patch.go b/core/commands/object/patch.go index aa022db5a52..0e8fd8d1160 100644 --- a/core/commands/object/patch.go +++ b/core/commands/object/patch.go @@ -60,7 +60,7 @@ the limit will not be respected by the network. return err } - data, err := req.Files.NextFile() + _, data, err := req.Files.NextFile() if err != nil { return err } @@ -107,7 +107,7 @@ Example: return err } - data, err := req.Files.NextFile() + _, data, err := req.Files.NextFile() if err != nil { return err } diff --git a/core/commands/tar.go b/core/commands/tar.go index 2a98494e27f..85e71b3de3c 100644 --- a/core/commands/tar.go +++ b/core/commands/tar.go @@ -44,7 +44,7 @@ represent it. return err } - fi, err := req.Files.NextFile() + name, fi, err := req.Files.NextFile() if err != nil { return err } @@ -56,9 +56,8 @@ represent it. c := node.Cid() - fi.FileName() return cmds.EmitOnce(res, &coreiface.AddEvent{ - Name: fi.FileName(), + Name: name, Hash: c.String(), }) }, diff --git a/core/coreapi/interface/unixfs.go b/core/coreapi/interface/unixfs.go index 3a214085c2a..773b36dc039 100644 --- a/core/coreapi/interface/unixfs.go +++ b/core/coreapi/interface/unixfs.go @@ -2,9 +2,8 @@ package iface import ( "context" - "io" - options "github.com/ipfs/go-ipfs/core/coreapi/interface/options" + "github.com/ipfs/go-ipfs/core/coreapi/interface/options" files "gx/ipfs/QmXWZCd8jfaHmt4UDSnjKmGcrQMw95bDGWqEeVLVJjoANX/go-ipfs-files" ipld "gx/ipfs/QmcKKBwfz6FyQdHR2jsXrrF6XeSBXYL86anmWNewpFpoF5/go-ipld-format" @@ -18,11 +17,6 @@ type AddEvent struct { Size string `json:",omitempty"` } -type UnixfsFile interface { - files.SizeFile - io.Seeker -} - // UnixfsAPI is the basic interface to immutable files in IPFS // NOTE: This API is heavily WIP, things are guaranteed to break frequently type UnixfsAPI interface { @@ -35,7 +29,7 @@ type UnixfsAPI interface { // // Note that some implementations of this API may apply the specified context // to operations performed on the returned file - Get(context.Context, Path) (UnixfsFile, error) + Get(context.Context, Path) (files.File, error) // Ls returns the list of links in a directory Ls(context.Context, Path) ([]*ipld.Link, error) diff --git a/core/coreapi/name_test.go b/core/coreapi/name_test.go index 1b64508f50b..85049b8b8cf 100644 --- a/core/coreapi/name_test.go +++ b/core/coreapi/name_test.go @@ -20,7 +20,7 @@ import ( var rnd = rand.New(rand.NewSource(0x62796532303137)) func addTestObject(ctx context.Context, api coreiface.CoreAPI) (coreiface.Path, error) { - return api.Unixfs().Add(ctx, files.NewReaderFile("", "", ioutil.NopCloser(&io.LimitedReader{R: rnd, N: 4092}), nil)) + return api.Unixfs().Add(ctx, files.NewReaderFile(ioutil.NopCloser(&io.LimitedReader{R: rnd, N: 4092}), nil)) } func appendPath(p coreiface.Path, sub string) coreiface.Path { diff --git a/core/coreapi/unixfile.go b/core/coreapi/unixfile.go index 1ff44e3bfa3..d2ef898871f 100644 --- a/core/coreapi/unixfile.go +++ b/core/coreapi/unixfile.go @@ -4,11 +4,6 @@ import ( "context" "errors" "io" - "os" - gopath "path" - "time" - - "github.com/ipfs/go-ipfs/core/coreapi/interface" files "gx/ipfs/QmXWZCd8jfaHmt4UDSnjKmGcrQMw95bDGWqEeVLVJjoANX/go-ipfs-files" ft "gx/ipfs/Qmbvw7kpSM2p6rbQ57WGRhhqNfCiNGW6EKH4xgHLw4bsnB/go-unixfs" @@ -23,44 +18,11 @@ const prefetchFiles = 4 // TODO: this probably belongs in go-unixfs (and could probably replace a chunk of it's interface in the long run) -type sizeInfo struct { - size int64 - name string - modTime time.Time -} - -func (s *sizeInfo) Name() string { - return s.name -} - -func (s *sizeInfo) Size() int64 { - return s.size -} - -func (s *sizeInfo) Mode() os.FileMode { - return 0444 // all read -} - -func (s *sizeInfo) ModTime() time.Time { - return s.modTime -} - -func (s *sizeInfo) IsDir() bool { - return false -} - -func (s *sizeInfo) Sys() interface{} { - return nil -} - type ufsDirectory struct { ctx context.Context dserv ipld.DAGService files chan *ipld.Link - - name string - path string } func (d *ufsDirectory) Close() error { @@ -71,30 +33,23 @@ func (d *ufsDirectory) Read(_ []byte) (int, error) { return 0, files.ErrNotReader } -func (d *ufsDirectory) FileName() string { - return d.name -} - -func (d *ufsDirectory) FullPath() string { - return d.path -} - func (d *ufsDirectory) IsDirectory() bool { return true } -func (d *ufsDirectory) NextFile() (files.File, error) { +func (d *ufsDirectory) NextFile() (string, files.File, error) { l, ok := <-d.files if !ok { - return nil, io.EOF + return "", nil, io.EOF } nd, err := l.GetNode(d.ctx, d.dserv) if err != nil { - return nil, err + return "", nil, err } - return newUnixfsFile(d.ctx, d.dserv, nd, l.Name, d) + f, err := newUnixfsFile(d.ctx, d.dserv, nd, d) + return l.Name, f, err } func (d *ufsDirectory) Size() (int64, error) { @@ -107,32 +62,21 @@ func (d *ufsDirectory) Seek(offset int64, whence int) (int64, error) { type ufsFile struct { uio.DagReader - - name string - path string } func (f *ufsFile) IsDirectory() bool { return false } -func (f *ufsFile) NextFile() (files.File, error) { - return nil, files.ErrNotDirectory -} - -func (f *ufsFile) FileName() string { - return f.name -} - -func (f *ufsFile) FullPath() string { - return f.path +func (f *ufsFile) NextFile() (string, files.File, error) { + return "", nil, files.ErrNotDirectory } func (f *ufsFile) Size() (int64, error) { return int64(f.DagReader.Size()), nil } -func newUnixfsDir(ctx context.Context, dserv ipld.DAGService, nd ipld.Node, name string, path string) (iface.UnixfsFile, error) { +func newUnixfsDir(ctx context.Context, dserv ipld.DAGService, nd ipld.Node) (files.File, error) { dir, err := uio.NewDirectoryFromNode(dserv, nd) if err != nil { return nil, err @@ -157,18 +101,10 @@ func newUnixfsDir(ctx context.Context, dserv ipld.DAGService, nd ipld.Node, name dserv: dserv, files: fileCh, - - name: name, - path: path, }, nil } -func newUnixfsFile(ctx context.Context, dserv ipld.DAGService, nd ipld.Node, name string, parent files.File) (iface.UnixfsFile, error) { - path := name - if parent != nil { - path = gopath.Join(parent.FullPath(), name) - } - +func newUnixfsFile(ctx context.Context, dserv ipld.DAGService, nd ipld.Node, parent files.File) (files.File, error) { switch dn := nd.(type) { case *dag.ProtoNode: fsn, err := ft.FSNodeFromBytes(dn.Data()) @@ -176,7 +112,7 @@ func newUnixfsFile(ctx context.Context, dserv ipld.DAGService, nd ipld.Node, nam return nil, err } if fsn.IsDir() { - return newUnixfsDir(ctx, dserv, nd, name, path) + return newUnixfsDir(ctx, dserv, nd) } case *dag.RawNode: @@ -191,10 +127,5 @@ func newUnixfsFile(ctx context.Context, dserv ipld.DAGService, nd ipld.Node, nam return &ufsFile{ DagReader: dr, - - name: name, - path: path, }, nil } - -var _ os.FileInfo = &sizeInfo{} diff --git a/core/coreapi/unixfs.go b/core/coreapi/unixfs.go index 4f129d6e012..f3c5038caf7 100644 --- a/core/coreapi/unixfs.go +++ b/core/coreapi/unixfs.go @@ -133,7 +133,7 @@ func (api *UnixfsAPI) Add(ctx context.Context, files files.File, opts ...options return coreiface.IpfsPath(nd.Cid()), nil } -func (api *UnixfsAPI) Get(ctx context.Context, p coreiface.Path) (coreiface.UnixfsFile, error) { +func (api *UnixfsAPI) Get(ctx context.Context, p coreiface.Path) (files.File, error) { ses := api.core().getSession(ctx) nd, err := ses.ResolveNode(ctx, p) @@ -141,7 +141,7 @@ func (api *UnixfsAPI) Get(ctx context.Context, p coreiface.Path) (coreiface.Unix return nil, err } - return newUnixfsFile(ctx, ses.dag, nd, "", nil) + return newUnixfsFile(ctx, ses.dag, nd, nil) } // Ls returns the contents of an IPFS or IPNS object(s) at path p, with the format: diff --git a/core/coreapi/unixfs_test.go b/core/coreapi/unixfs_test.go index 228c04a0501..38b91036e75 100644 --- a/core/coreapi/unixfs_test.go +++ b/core/coreapi/unixfs_test.go @@ -8,7 +8,6 @@ import ( "io" "io/ioutil" "math" - "os" "strconv" "strings" "sync" @@ -136,33 +135,36 @@ func makeAPI(ctx context.Context) (*core.IpfsNode, coreiface.CoreAPI, error) { func strFile(data string) func() files.File { return func() files.File { - return files.NewReaderFile("", "", ioutil.NopCloser(strings.NewReader(data)), nil) + return files.NewReaderFile(ioutil.NopCloser(strings.NewReader(data)), nil) } } func twoLevelDir() func() files.File { return func() files.File { - return files.NewSliceFile("t", "t", []files.File{ - files.NewSliceFile("t/abc", "t/abc", []files.File{ - files.NewReaderFile("t/abc/def", "t/abc/def", ioutil.NopCloser(strings.NewReader("world")), nil), - }), - files.NewReaderFile("t/bar", "t/bar", ioutil.NopCloser(strings.NewReader("hello2")), nil), - files.NewReaderFile("t/foo", "t/foo", ioutil.NopCloser(strings.NewReader("hello1")), nil), + return files.NewSliceFile([]files.FileEntry{{ + Name: "abc", File: files.NewSliceFile([]files.FileEntry{ + {Name: "def", File: files.NewReaderFile(ioutil.NopCloser(strings.NewReader("world")), nil)}, + })}, + + {Name: "bar", File: files.NewReaderFile(ioutil.NopCloser(strings.NewReader("hello2")), nil)}, + {Name: "foo", File: files.NewReaderFile(ioutil.NopCloser(strings.NewReader("hello1")), nil)}, }) } } func flatDir() files.File { - return files.NewSliceFile("t", "t", []files.File{ - files.NewReaderFile("t/bar", "t/bar", ioutil.NopCloser(strings.NewReader("hello2")), nil), - files.NewReaderFile("t/foo", "t/foo", ioutil.NopCloser(strings.NewReader("hello1")), nil), + return files.NewSliceFile([]files.FileEntry{ + {Name: "bar", File: files.NewReaderFile(ioutil.NopCloser(strings.NewReader("hello2")), nil)}, + {Name: "foo", File: files.NewReaderFile(ioutil.NopCloser(strings.NewReader("hello1")), nil)}, }) } -func wrapped(f files.File) files.File { - return files.NewSliceFile("", "", []files.File{ - f, - }) +func wrapped(name string) func(f files.File) files.File { + return func(f files.File) files.File { + return files.NewSliceFile([]files.FileEntry{ + {Name: name, File: f}, + }) + } } func TestAdd(t *testing.T) { @@ -180,7 +182,7 @@ func TestAdd(t *testing.T) { path string err string - recursive bool + wrap string events []coreiface.AddEvent @@ -277,36 +279,36 @@ func TestAdd(t *testing.T) { }, // multi file { - name: "simpleDir", - data: flatDir, - recursive: true, - path: "/ipfs/QmRKGpFfR32FVXdvJiHfo4WJ5TDYBsM1P9raAp1p6APWSp", + name: "simpleDir", + data: flatDir, + wrap: "t", + path: "/ipfs/QmRKGpFfR32FVXdvJiHfo4WJ5TDYBsM1P9raAp1p6APWSp", }, { - name: "twoLevelDir", - data: twoLevelDir(), - recursive: true, - path: "/ipfs/QmVG2ZYCkV1S4TK8URA3a4RupBF17A8yAr4FqsRDXVJASr", + name: "twoLevelDir", + data: twoLevelDir(), + wrap: "t", + path: "/ipfs/QmVG2ZYCkV1S4TK8URA3a4RupBF17A8yAr4FqsRDXVJASr", }, // wrapped { name: "addWrapped", path: "/ipfs/QmVE9rNpj5doj7XHzp5zMUxD7BJgXEqx4pe3xZ3JBReWHE", data: func() files.File { - return files.NewReaderFile("foo", "foo", ioutil.NopCloser(strings.NewReader(helloStr)), nil) + return files.NewReaderFile(ioutil.NopCloser(strings.NewReader(helloStr)), nil) }, - expect: wrapped, + expect: wrapped("foo"), opts: []options.UnixfsAddOption{options.Unixfs.Wrap(true)}, }, { name: "stdinWrapped", path: "/ipfs/QmU3r81oZycjHS9oaSHw37ootMFuFUw1DvMLKXPsezdtqU", data: func() files.File { - return files.NewReaderFile("", os.Stdin.Name(), ioutil.NopCloser(strings.NewReader(helloStr)), nil) + return files.NewReaderFile(ioutil.NopCloser(strings.NewReader(helloStr)), nil) }, expect: func(files.File) files.File { - return files.NewSliceFile("", "", []files.File{ - files.NewReaderFile("QmQy2Dw4Wk7rdJKjThjYXzfFJNaRKRHhHP5gHHXroJMYxk", "QmQy2Dw4Wk7rdJKjThjYXzfFJNaRKRHhHP5gHHXroJMYxk", ioutil.NopCloser(strings.NewReader(helloStr)), nil), + return files.NewSliceFile([]files.FileEntry{ + {Name: "QmQy2Dw4Wk7rdJKjThjYXzfFJNaRKRHhHP5gHHXroJMYxk", File: files.NewReaderFile(ioutil.NopCloser(strings.NewReader(helloStr)), nil)}, }) }, opts: []options.UnixfsAddOption{options.Unixfs.Wrap(true)}, @@ -315,68 +317,68 @@ func TestAdd(t *testing.T) { name: "stdinNamed", path: "/ipfs/QmQ6cGBmb3ZbdrQW1MRm1RJnYnaxCqfssz7CrTa9NEhQyS", data: func() files.File { - return files.NewReaderFile("", os.Stdin.Name(), ioutil.NopCloser(strings.NewReader(helloStr)), nil) + return files.NewReaderFile(ioutil.NopCloser(strings.NewReader(helloStr)), nil) }, expect: func(files.File) files.File { - return files.NewSliceFile("", "", []files.File{ - files.NewReaderFile("test", "test", ioutil.NopCloser(strings.NewReader(helloStr)), nil), + return files.NewSliceFile([]files.FileEntry{ + {Name: "test", File: files.NewReaderFile(ioutil.NopCloser(strings.NewReader(helloStr)), nil)}, }) }, opts: []options.UnixfsAddOption{options.Unixfs.Wrap(true), options.Unixfs.StdinName("test")}, }, { - name: "twoLevelDirWrapped", - data: twoLevelDir(), - recursive: true, - expect: wrapped, - path: "/ipfs/QmPwsL3T5sWhDmmAWZHAzyjKtMVDS9a11aHNRqb3xoVnmg", - opts: []options.UnixfsAddOption{options.Unixfs.Wrap(true)}, + name: "twoLevelDirWrapped", + data: twoLevelDir(), + wrap: "t", + expect: wrapped(""), + path: "/ipfs/QmPwsL3T5sWhDmmAWZHAzyjKtMVDS9a11aHNRqb3xoVnmg", + opts: []options.UnixfsAddOption{options.Unixfs.Wrap(true)}, }, { - name: "twoLevelInlineHash", - data: twoLevelDir(), - recursive: true, - expect: wrapped, - path: "/ipfs/zBunoruKoyCHKkALNSWxDvj4L7yuQnMgQ4hUa9j1Z64tVcDEcu6Zdetyu7eeFCxMPfxb7YJvHeFHoFoHMkBUQf6vfdhmi", - opts: []options.UnixfsAddOption{options.Unixfs.Wrap(true), options.Unixfs.Inline(true), options.Unixfs.RawLeaves(true), options.Unixfs.Hash(mh.SHA3)}, + name: "twoLevelInlineHash", + data: twoLevelDir(), + wrap: "t", + expect: wrapped(""), + path: "/ipfs/zBunoruKoyCHKkALNSWxDvj4L7yuQnMgQ4hUa9j1Z64tVcDEcu6Zdetyu7eeFCxMPfxb7YJvHeFHoFoHMkBUQf6vfdhmi", + opts: []options.UnixfsAddOption{options.Unixfs.Wrap(true), options.Unixfs.Inline(true), options.Unixfs.RawLeaves(true), options.Unixfs.Hash(mh.SHA3)}, }, // hidden { name: "hiddenFiles", data: func() files.File { - return files.NewSliceFile("t", "t", []files.File{ - files.NewReaderFile("t/.bar", "t/.bar", ioutil.NopCloser(strings.NewReader("hello2")), nil), - files.NewReaderFile("t/bar", "t/bar", ioutil.NopCloser(strings.NewReader("hello2")), nil), - files.NewReaderFile("t/foo", "t/foo", ioutil.NopCloser(strings.NewReader("hello1")), nil), + return files.NewSliceFile([]files.FileEntry{ + {Name: ".bar", File: files.NewReaderFile(ioutil.NopCloser(strings.NewReader("hello2")), nil)}, + {Name: "bar", File: files.NewReaderFile(ioutil.NopCloser(strings.NewReader("hello2")), nil)}, + {Name: "foo", File: files.NewReaderFile(ioutil.NopCloser(strings.NewReader("hello1")), nil)}, }) }, - recursive: true, - path: "/ipfs/QmehGvpf2hY196MzDFmjL8Wy27S4jbgGDUAhBJyvXAwr3g", - opts: []options.UnixfsAddOption{options.Unixfs.Hidden(true)}, + wrap: "t", + path: "/ipfs/QmehGvpf2hY196MzDFmjL8Wy27S4jbgGDUAhBJyvXAwr3g", + opts: []options.UnixfsAddOption{options.Unixfs.Hidden(true)}, }, { name: "hiddenFileAlwaysAdded", data: func() files.File { - return files.NewReaderFile(".foo", ".foo", ioutil.NopCloser(strings.NewReader(helloStr)), nil) + return files.NewReaderFile(ioutil.NopCloser(strings.NewReader(helloStr)), nil) }, - recursive: true, - path: hello, + wrap: ".foo", + path: hello, }, { name: "hiddenFilesNotAdded", data: func() files.File { - return files.NewSliceFile("t", "t", []files.File{ - files.NewReaderFile("t/.bar", "t/.bar", ioutil.NopCloser(strings.NewReader("hello2")), nil), - files.NewReaderFile("t/bar", "t/bar", ioutil.NopCloser(strings.NewReader("hello2")), nil), - files.NewReaderFile("t/foo", "t/foo", ioutil.NopCloser(strings.NewReader("hello1")), nil), + return files.NewSliceFile([]files.FileEntry{ + {Name: ".bar", File: files.NewReaderFile(ioutil.NopCloser(strings.NewReader("hello2")), nil)}, + {Name: "bar", File: files.NewReaderFile(ioutil.NopCloser(strings.NewReader("hello2")), nil)}, + {Name: "foo", File: files.NewReaderFile(ioutil.NopCloser(strings.NewReader("hello1")), nil)}, }) }, expect: func(files.File) files.File { return flatDir() }, - recursive: true, - path: "/ipfs/QmRKGpFfR32FVXdvJiHfo4WJ5TDYBsM1P9raAp1p6APWSp", - opts: []options.UnixfsAddOption{options.Unixfs.Hidden(false)}, + wrap: "t", + path: "/ipfs/QmRKGpFfR32FVXdvJiHfo4WJ5TDYBsM1P9raAp1p6APWSp", + opts: []options.UnixfsAddOption{options.Unixfs.Hidden(false)}, }, // Events / Progress { @@ -396,8 +398,8 @@ func TestAdd(t *testing.T) { {Name: "t/abc", Hash: "QmU7nuGs2djqK99UNsNgEPGh6GV4662p6WtsgccBNGTDxt", Size: "62"}, {Name: "t", Hash: "QmVG2ZYCkV1S4TK8URA3a4RupBF17A8yAr4FqsRDXVJASr", Size: "229"}, }, - recursive: true, - opts: []options.UnixfsAddOption{options.Unixfs.Silent(true)}, + wrap: "t", + opts: []options.UnixfsAddOption{options.Unixfs.Silent(true)}, }, { name: "dirAddEvents", @@ -410,13 +412,13 @@ func TestAdd(t *testing.T) { {Name: "t/abc", Hash: "QmU7nuGs2djqK99UNsNgEPGh6GV4662p6WtsgccBNGTDxt", Size: "62"}, {Name: "t", Hash: "QmVG2ZYCkV1S4TK8URA3a4RupBF17A8yAr4FqsRDXVJASr", Size: "229"}, }, - recursive: true, + wrap: "t", }, { name: "progress1M", data: func() files.File { r := bytes.NewReader(bytes.Repeat([]byte{0}, 1000000)) - return files.NewReaderFile("", "", ioutil.NopCloser(r), nil) + return files.NewReaderFile(ioutil.NopCloser(r), nil) }, path: "/ipfs/QmXXNNbwe4zzpdMg62ZXvnX1oU7MwSrQ3vAEtuwFKCm1oD", events: []coreiface.AddEvent{ @@ -426,8 +428,8 @@ func TestAdd(t *testing.T) { {Name: "", Bytes: 1000000}, {Name: "QmXXNNbwe4zzpdMg62ZXvnX1oU7MwSrQ3vAEtuwFKCm1oD", Hash: "QmXXNNbwe4zzpdMg62ZXvnX1oU7MwSrQ3vAEtuwFKCm1oD", Size: "1000256"}, }, - recursive: true, - opts: []options.UnixfsAddOption{options.Unixfs.Progress(true)}, + wrap: "t", + opts: []options.UnixfsAddOption{options.Unixfs.Progress(true)}, }, } @@ -439,9 +441,9 @@ func TestAdd(t *testing.T) { // recursive logic data := testCase.data() - if testCase.recursive { - data = files.NewSliceFile("", "", []files.File{ - data, + if testCase.wrap != "" { + data = files.NewSliceFile([]files.FileEntry{ + {Name: testCase.wrap, File: data}, }) } @@ -516,12 +518,16 @@ func TestAdd(t *testing.T) { // compare file structure with Unixfs().Get - var cmpFile func(orig files.File, got files.File) - cmpFile = func(orig files.File, got files.File) { + var cmpFile func(origName string, orig files.File, gotName string, got files.File) + cmpFile = func(origName string, orig files.File, gotName string, got files.File) { if orig.IsDirectory() != got.IsDirectory() { t.Fatal("file type mismatch") } + if origName != gotName { + t.Fatal("file name mismatch") + } + if !orig.IsDirectory() { defer orig.Close() defer got.Close() @@ -544,8 +550,8 @@ func TestAdd(t *testing.T) { } for { - fo, err := orig.NextFile() - fg, err2 := got.NextFile() + origName, origFile, err := orig.NextFile() + gotName, gotFile, err2 := got.NextFile() if err != nil { if err == io.EOF && err2 == io.EOF { @@ -557,7 +563,7 @@ func TestAdd(t *testing.T) { t.Fatal(err) } - cmpFile(fo, fg) + cmpFile(origName, origFile, gotName, gotFile) } } @@ -571,7 +577,7 @@ func TestAdd(t *testing.T) { orig = testCase.expect(orig) } - cmpFile(orig, f) + cmpFile("", orig, "", f) }) } } diff --git a/core/corehttp/gateway_handler.go b/core/corehttp/gateway_handler.go index 3379689f45f..103916c7783 100644 --- a/core/corehttp/gateway_handler.go +++ b/core/corehttp/gateway_handler.go @@ -386,7 +386,7 @@ func (i *gatewayHandler) serveFile(w http.ResponseWriter, req *http.Request, nam } func (i *gatewayHandler) postHandler(ctx context.Context, w http.ResponseWriter, r *http.Request) { - p, err := i.api.Unixfs().Add(ctx, files.NewReaderFile("", "", ioutil.NopCloser(r.Body), nil)) + p, err := i.api.Unixfs().Add(ctx, files.NewReaderFile(ioutil.NopCloser(r.Body), nil)) if err != nil { internalWebError(w, err) return diff --git a/core/coreunix/add.go b/core/coreunix/add.go index 868bd5d7ef7..fcfa4aa6e10 100644 --- a/core/coreunix/add.go +++ b/core/coreunix/add.go @@ -311,7 +311,7 @@ func AddR(n *core.IpfsNode, root string) (key string, err error) { return "", err } - f, err := files.NewSerialFile(filepath.Base(root), root, false, stat) + f, err := files.NewSerialFile(root, false, stat) if err != nil { return "", err } @@ -322,7 +322,7 @@ func AddR(n *core.IpfsNode, root string) (key string, err error) { return "", err } - err = fileAdder.addFile(f) + err = fileAdder.addFile(filepath.Base(root), f) if err != nil { return "", err } @@ -340,7 +340,7 @@ func AddR(n *core.IpfsNode, root string) (key string, err error) { // Returns the path of the added file ("/filename"), the DAG node of // the directory, and and error if any. func AddWrapped(n *core.IpfsNode, r io.Reader, filename string) (string, ipld.Node, error) { - file := files.NewReaderFile(filename, filename, ioutil.NopCloser(r), nil) + file := files.NewReaderFile(ioutil.NopCloser(r), nil) fileAdder, err := NewAdder(n.Context(), n.Pinning, n.Blockstore, n.DAG) if err != nil { return "", nil, err @@ -349,7 +349,7 @@ func AddWrapped(n *core.IpfsNode, r io.Reader, filename string) (string, ipld.No defer n.Blockstore.PinLock().Unlock() - err = fileAdder.addFile(file) + err = fileAdder.addFile(filename, file) if err != nil { return "", nil, err } @@ -416,20 +416,20 @@ func (adder *Adder) AddAllAndPin(file files.File) (ipld.Node, error) { // single files.File f is treated as a directory, affecting hidden file // semantics. for { - f, err := file.NextFile() + name, f, err := file.NextFile() if err == io.EOF { // Finished the list of files. break } else if err != nil { return nil, err } - if err := adder.addFile(f); err != nil { + if err := adder.addFile(name, f); err != nil { return nil, err } } break default: - if err := adder.addFile(file); err != nil { + if err := adder.addFile("", file); err != nil { return nil, err } break @@ -447,7 +447,7 @@ func (adder *Adder) AddAllAndPin(file files.File) (ipld.Node, error) { return nd, adder.PinRoot() } -func (adder *Adder) addFile(file files.File) error { +func (adder *Adder) addFile(path string, file files.File) error { err := adder.maybePauseForGC() if err != nil { return err @@ -468,7 +468,7 @@ func (adder *Adder) addFile(file files.File) error { adder.liveNodes++ if file.IsDirectory() { - return adder.addDir(file) + return adder.addDir(path, file) } // case for symlink @@ -485,7 +485,7 @@ func (adder *Adder) addFile(file files.File) error { return err } - return adder.addNode(dagnode, s.FileName()) + return adder.addNode(dagnode, path) } // case for regular file @@ -493,7 +493,7 @@ func (adder *Adder) addFile(file files.File) error { // progress updates to the client (over the output channel) var reader io.Reader = file if adder.Progress { - rdr := &progressReader{file: file, out: adder.Out} + rdr := &progressReader{file: file, path: path, out: adder.Out} if fi, ok := file.(files.FileInfo); ok { reader = &progressReader2{rdr, fi} } else { @@ -506,26 +506,25 @@ func (adder *Adder) addFile(file files.File) error { return err } - addFileName := file.FileName() addFileInfo, ok := file.(files.FileInfo) if ok { if addFileInfo.AbsPath() == os.Stdin.Name() && adder.Name != "" { - addFileName = adder.Name + path = adder.Name adder.Name = "" } } // patch it into the root - return adder.addNode(dagnode, addFileName) + return adder.addNode(dagnode, path) } -func (adder *Adder) addDir(dir files.File) error { - log.Infof("adding directory: %s", dir.FileName()) +func (adder *Adder) addDir(path string, dir files.File) error { + log.Infof("adding directory: %s", path) mr, err := adder.mfsRoot() if err != nil { return err } - err = mfs.Mkdir(mr, dir.FileName(), mfs.MkdirOpts{ + err = mfs.Mkdir(mr, path, mfs.MkdirOpts{ Mkparents: true, Flush: false, CidBuilder: adder.CidBuilder, @@ -535,7 +534,7 @@ func (adder *Adder) addDir(dir files.File) error { } for { - file, err := dir.NextFile() + name, file, err := dir.NextFile() if err != nil && err != io.EOF { return err } @@ -543,12 +542,14 @@ func (adder *Adder) addDir(dir files.File) error { break } + fpath := gopath.Join(path, name) + // Skip hidden files when adding recursively, unless Hidden is enabled. - if files.IsHidden(file) && !adder.Hidden { - log.Infof("%s is hidden, skipping", file.FileName()) + if files.IsHidden(fpath, file) && !adder.Hidden { + log.Infof("%s is hidden, skipping", fpath) continue } - err = adder.addFile(file) + err = adder.addFile(fpath, file) if err != nil { return err } @@ -616,6 +617,7 @@ func getOutput(dagnode ipld.Node) (*Object, error) { type progressReader struct { file files.File + path string out chan<- interface{} bytes int64 lastProgress int64 @@ -628,7 +630,7 @@ func (i *progressReader) Read(p []byte) (int, error) { if i.bytes-i.lastProgress >= progressReaderIncrement || err == io.EOF { i.lastProgress = i.bytes i.out <- &coreiface.AddEvent{ - Name: i.file.FileName(), + Name: i.path, Bytes: i.bytes, } } @@ -640,3 +642,7 @@ type progressReader2 struct { *progressReader files.FileInfo } + +func (i *progressReader2) Read(p []byte) (int, error) { + return i.progressReader.Read(p) +} diff --git a/core/coreunix/add_test.go b/core/coreunix/add_test.go index a96a63c1d90..eb2e70a6875 100644 --- a/core/coreunix/add_test.go +++ b/core/coreunix/add_test.go @@ -71,16 +71,20 @@ func TestAddGCLive(t *testing.T) { adder.Out = out dataa := ioutil.NopCloser(bytes.NewBufferString("testfileA")) - rfa := files.NewReaderFile("a", "a", dataa, nil) + rfa := files.NewReaderFile(dataa, nil) // make two files with pipes so we can 'pause' the add for timing of the test piper, pipew := io.Pipe() - hangfile := files.NewReaderFile("b", "b", piper, nil) + hangfile := files.NewReaderFile(piper, nil) datad := ioutil.NopCloser(bytes.NewBufferString("testfileD")) - rfd := files.NewReaderFile("d", "d", datad, nil) + rfd := files.NewReaderFile(datad, nil) - slf := files.NewSliceFile("files", "files", []files.File{rfa, hangfile, rfd}) + slf := files.NewSliceFile([]files.FileEntry{ + {File: rfa, Name: "a"}, + {File: hangfile, Name: "b"}, + {File: rfd, Name: "d"}, + }) addDone := make(chan struct{}) go func() { @@ -189,7 +193,7 @@ func testAddWPosInfo(t *testing.T, rawLeaves bool) { rand.New(rand.NewSource(2)).Read(data) // Rand.Read never returns an error fileData := ioutil.NopCloser(bytes.NewBuffer(data)) fileInfo := dummyFileInfo{"foo.txt", int64(len(data)), time.Now()} - file := files.NewReaderFile("foo.txt", "/tmp/foo.txt", fileData, &fileInfo) + file := files.NewReaderFile(fileData, &fileInfo) go func() { defer close(adder.Out) From a96b370ee28281a2beeb3365889469fadc96ba52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Fri, 26 Oct 2018 16:42:01 +0200 Subject: [PATCH 03/16] files2.0: Fix coreapi.unixfs.Add tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit License: MIT Signed-off-by: Łukasz Magiera --- core/coreapi/unixfs_test.go | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/core/coreapi/unixfs_test.go b/core/coreapi/unixfs_test.go index 38b91036e75..a3949072a3c 100644 --- a/core/coreapi/unixfs_test.go +++ b/core/coreapi/unixfs_test.go @@ -8,6 +8,7 @@ import ( "io" "io/ioutil" "math" + "os" "strconv" "strings" "sync" @@ -297,9 +298,18 @@ func TestAdd(t *testing.T) { data: func() files.File { return files.NewReaderFile(ioutil.NopCloser(strings.NewReader(helloStr)), nil) }, + wrap: "foo", expect: wrapped("foo"), opts: []options.UnixfsAddOption{options.Unixfs.Wrap(true)}, }, + { + name: "addNotWrappedDirFile", + path: hello, + data: func() files.File { + return files.NewReaderFile(ioutil.NopCloser(strings.NewReader(helloStr)), nil) + }, + wrap: "foo", + }, { name: "stdinWrapped", path: "/ipfs/QmU3r81oZycjHS9oaSHw37ootMFuFUw1DvMLKXPsezdtqU", @@ -317,7 +327,12 @@ func TestAdd(t *testing.T) { name: "stdinNamed", path: "/ipfs/QmQ6cGBmb3ZbdrQW1MRm1RJnYnaxCqfssz7CrTa9NEhQyS", data: func() files.File { - return files.NewReaderFile(ioutil.NopCloser(strings.NewReader(helloStr)), nil) + rf, err := files.NewReaderPathFile(os.Stdin.Name(), ioutil.NopCloser(strings.NewReader(helloStr)), nil) + if err != nil { + panic(err) + } + + return rf }, expect: func(files.File) files.File { return files.NewSliceFile([]files.FileEntry{ @@ -330,7 +345,7 @@ func TestAdd(t *testing.T) { name: "twoLevelDirWrapped", data: twoLevelDir(), wrap: "t", - expect: wrapped(""), + expect: wrapped("t"), path: "/ipfs/QmPwsL3T5sWhDmmAWZHAzyjKtMVDS9a11aHNRqb3xoVnmg", opts: []options.UnixfsAddOption{options.Unixfs.Wrap(true)}, }, @@ -338,7 +353,7 @@ func TestAdd(t *testing.T) { name: "twoLevelInlineHash", data: twoLevelDir(), wrap: "t", - expect: wrapped(""), + expect: wrapped("t"), path: "/ipfs/zBunoruKoyCHKkALNSWxDvj4L7yuQnMgQ4hUa9j1Z64tVcDEcu6Zdetyu7eeFCxMPfxb7YJvHeFHoFoHMkBUQf6vfdhmi", opts: []options.UnixfsAddOption{options.Unixfs.Wrap(true), options.Unixfs.Inline(true), options.Unixfs.RawLeaves(true), options.Unixfs.Hash(mh.SHA3)}, }, @@ -428,7 +443,7 @@ func TestAdd(t *testing.T) { {Name: "", Bytes: 1000000}, {Name: "QmXXNNbwe4zzpdMg62ZXvnX1oU7MwSrQ3vAEtuwFKCm1oD", Hash: "QmXXNNbwe4zzpdMg62ZXvnX1oU7MwSrQ3vAEtuwFKCm1oD", Size: "1000256"}, }, - wrap: "t", + wrap: "", opts: []options.UnixfsAddOption{options.Unixfs.Progress(true)}, }, } @@ -525,7 +540,7 @@ func TestAdd(t *testing.T) { } if origName != gotName { - t.Fatal("file name mismatch") + t.Errorf("file name mismatch, orig='%s', got='%s'", origName, gotName) } if !orig.IsDirectory() { From b8a773da0a9f89faf7128d02836d4a88b8945c59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Fri, 26 Oct 2018 17:04:13 +0200 Subject: [PATCH 04/16] files2.0: Rebase gx fixes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit License: MIT Signed-off-by: Łukasz Magiera --- core/coreapi/unixfs_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/coreapi/unixfs_test.go b/core/coreapi/unixfs_test.go index a3949072a3c..8b773dd96d2 100644 --- a/core/coreapi/unixfs_test.go +++ b/core/coreapi/unixfs_test.go @@ -298,7 +298,7 @@ func TestAdd(t *testing.T) { data: func() files.File { return files.NewReaderFile(ioutil.NopCloser(strings.NewReader(helloStr)), nil) }, - wrap: "foo", + wrap: "foo", expect: wrapped("foo"), opts: []options.UnixfsAddOption{options.Unixfs.Wrap(true)}, }, From a43f2f85b8a9fae6ac57d7b5aa942d77d1df95de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Mon, 5 Nov 2018 17:33:41 +0100 Subject: [PATCH 05/16] files2.0: fix AddPosInfo test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit License: MIT Signed-off-by: Łukasz Magiera --- core/coreunix/add_test.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/core/coreunix/add_test.go b/core/coreunix/add_test.go index eb2e70a6875..b1f5be3c93a 100644 --- a/core/coreunix/add_test.go +++ b/core/coreunix/add_test.go @@ -7,6 +7,7 @@ import ( "io/ioutil" "math/rand" "os" + "path/filepath" "testing" "time" @@ -176,7 +177,7 @@ func testAddWPosInfo(t *testing.T, rawLeaves bool) { t.Fatal(err) } - bs := &testBlockstore{GCBlockstore: node.Blockstore, expectedPath: "/tmp/foo.txt", t: t} + bs := &testBlockstore{GCBlockstore: node.Blockstore, expectedPath: filepath.Join(os.TempDir(), "foo.txt"), t: t} bserv := blockservice.New(bs, node.Exchange) dserv := dag.NewDAGService(bserv) adder, err := NewAdder(context.Background(), node.Pinning, bs, dserv) @@ -193,7 +194,7 @@ func testAddWPosInfo(t *testing.T, rawLeaves bool) { rand.New(rand.NewSource(2)).Read(data) // Rand.Read never returns an error fileData := ioutil.NopCloser(bytes.NewBuffer(data)) fileInfo := dummyFileInfo{"foo.txt", int64(len(data)), time.Now()} - file := files.NewReaderFile(fileData, &fileInfo) + file, _ := files.NewReaderPathFile(filepath.Join(os.TempDir(), "foo.txt"), fileData, &fileInfo) go func() { defer close(adder.Out) @@ -212,7 +213,7 @@ func testAddWPosInfo(t *testing.T, rawLeaves bool) { nonOffZero = 19 } if bs.countAtOffsetZero != exp { - t.Fatalf("expected %d blocks with an offset at zero (one root and one leafh), got %d", exp, bs.countAtOffsetZero) + t.Fatalf("expected %d blocks with an offset at zero (one root and one leaf), got %d", exp, bs.countAtOffsetZero) } if bs.countAtOffsetNonZero != nonOffZero { // note: the exact number will depend on the size and the sharding algo. used From adc74907554e7018b5a173e0621ada07f73d04c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Mon, 19 Nov 2018 03:24:42 +0100 Subject: [PATCH 06/16] files2.0: updates for file type split MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit License: MIT Signed-off-by: Łukasz Magiera --- cmd/ipfs/init.go | 11 +- core/commands/add.go | 1 - core/commands/block.go | 11 +- core/commands/cat.go | 6 +- core/commands/config.go | 10 +- core/commands/dag/dag.go | 17 ++- core/commands/files.go | 11 +- core/commands/object/object.go | 11 +- core/commands/object/patch.go | 28 +++-- core/commands/tar.go | 13 +- core/coreapi/interface/unixfs.go | 4 +- core/coreapi/unixfile.go | 108 ++++++++++------- core/coreapi/unixfs.go | 6 +- core/coreapi/unixfs_test.go | 141 ++++++++++++---------- core/corehttp/gateway_handler.go | 28 +++-- core/coreunix/add.go | 62 +++++----- core/coreunix/add_test.go | 8 +- fuse/readonly/ipfs_test.go | 3 +- test/integration/addcat_test.go | 2 +- test/integration/bench_cat_test.go | 2 +- test/integration/three_legged_cat_test.go | 2 +- 21 files changed, 275 insertions(+), 210 deletions(-) diff --git a/cmd/ipfs/init.go b/cmd/ipfs/init.go index 9d4bb51a418..9dc4f7fb806 100644 --- a/cmd/ipfs/init.go +++ b/cmd/ipfs/init.go @@ -85,13 +85,16 @@ environment variable: f := req.Files if f != nil { - _, confFile, err := f.NextFile() - if err != nil { - return err + it, _ := req.Files.Entries() + if !it.Next() && it.Err() != nil { + return it.Err() + } + if it.File() == nil { + return fmt.Errorf("expected a regular file") } conf = &config.Config{} - if err := json.NewDecoder(confFile).Decode(conf); err != nil { + if err := json.NewDecoder(it.File()).Decode(conf); err != nil { return err } } diff --git a/core/commands/add.go b/core/commands/add.go index 0585193225d..148e3a76bdc 100644 --- a/core/commands/add.go +++ b/core/commands/add.go @@ -11,7 +11,6 @@ import ( "github.com/ipfs/go-ipfs/core/coreapi/interface/options" pb "gx/ipfs/QmPtj12fdwuAqj9sBSTNUxBNu8kCGNp8b3o8yUzMm5GHpq/pb" - files "gx/ipfs/QmXWZCd8jfaHmt4UDSnjKmGcrQMw95bDGWqEeVLVJjoANX/go-ipfs-files" cmds "gx/ipfs/QmaAP56JAwdjwisPTu4yx17whcjTr6y5JCSCF77Y1rahWV/go-ipfs-cmds" cmdkit "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit" mh "gx/ipfs/QmerPMzPk1mJVowm8KgmoknWa4yCYvvugMPsgWmDNUvDLW/go-multihash" diff --git a/core/commands/block.go b/core/commands/block.go index 054e621d80b..b50f4c141ee 100644 --- a/core/commands/block.go +++ b/core/commands/block.go @@ -153,9 +153,12 @@ than 'sha2-256' or format to anything other than 'v0' will result in CIDv1. return err } - _, file, err := req.Files.NextFile() - if err != nil { - return err + it, _ := req.Files.Entries() + if !it.Next() && it.Err() != nil { + return it.Err() + } + if it.File() == nil { + return fmt.Errorf("expected a regular file") } mhtype, _ := req.Options[mhtypeOptionName].(string) @@ -178,7 +181,7 @@ than 'sha2-256' or format to anything other than 'v0' will result in CIDv1. } } - p, err := api.Block().Put(req.Context, file, options.Block.Hash(mhtval, mhlen), options.Block.Format(format)) + p, err := api.Block().Put(req.Context, it.File(), options.Block.Hash(mhtval, mhlen), options.Block.Format(format)) if err != nil { return err } diff --git a/core/commands/cat.go b/core/commands/cat.go index 3fa2fec09c9..734316927ec 100644 --- a/core/commands/cat.go +++ b/core/commands/cat.go @@ -9,6 +9,7 @@ import ( "github.com/ipfs/go-ipfs/core/commands/cmdenv" "github.com/ipfs/go-ipfs/core/coreapi/interface" + "gx/ipfs/QmXWZCd8jfaHmt4UDSnjKmGcrQMw95bDGWqEeVLVJjoANX/go-ipfs-files" cmds "gx/ipfs/QmaAP56JAwdjwisPTu4yx17whcjTr6y5JCSCF77Y1rahWV/go-ipfs-cmds" "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit" ) @@ -122,12 +123,13 @@ func cat(ctx context.Context, api iface.CoreAPI, paths []string, offset int64, m return nil, 0, err } - file, err := api.Unixfs().Get(ctx, fpath) + f, err := api.Unixfs().Get(ctx, fpath) if err != nil { return nil, 0, err } - if file.IsDirectory() { + file, ok := f.(files.File) + if !ok { return nil, 0, iface.ErrIsDir } diff --git a/core/commands/config.go b/core/commands/config.go index 45f9308402f..e2fc32b0cfa 100644 --- a/core/commands/config.go +++ b/core/commands/config.go @@ -280,10 +280,14 @@ can't be undone. } defer r.Close() - file, err := req.Files.NextFile() - if err != nil { - return err + it, _ := req.Files.Entries() + if !it.Next() && it.Err() != nil { + return it.Err() + } + if it.File() == nil { + return fmt.Errorf("expected a regular file") } + file := it.File() defer file.Close() return replaceConfig(r, file) diff --git a/core/commands/dag/dag.go b/core/commands/dag/dag.go index 1e3b0441e52..0da4af91a71 100644 --- a/core/commands/dag/dag.go +++ b/core/commands/dag/dag.go @@ -92,16 +92,12 @@ into an object of the specified format. defer nd.Blockstore.PinLock().Unlock() } - for { - _, file, err := req.Files.NextFile() - if err == io.EOF { - // Finished the list of files. - break - } else if err != nil { - return err + it, _ := req.Files.Entries() + for it.Next() { + if it.File() == nil { + return fmt.Errorf("expected a regular file") } - - nds, err := coredag.ParseInputs(ienc, format, file, mhType, -1) + nds, err := coredag.ParseInputs(ienc, format, it.File(), mhType, -1) if err != nil { return err } @@ -122,6 +118,9 @@ into an object of the specified format. return err } } + if it.Err() != nil { + return err + } if err := b.Commit(); err != nil { return err diff --git a/core/commands/files.go b/core/commands/files.go index eeff856a7ce..2792bad9844 100644 --- a/core/commands/files.go +++ b/core/commands/files.go @@ -769,12 +769,15 @@ stat' on the file or any of its ancestors. return err } - _, input, err := req.Files.NextFile() - if err != nil { - return err + it, _ := req.Files.Entries() + if !it.Next() && it.Err() != nil { + return it.Err() + } + if it.File() == nil { + return fmt.Errorf("expected a regular file") } - var r io.Reader = input + var r io.Reader = it.File() if countfound { r = io.LimitReader(r, int64(count)) } diff --git a/core/commands/object/object.go b/core/commands/object/object.go index bba3abae5b5..c21a193e220 100644 --- a/core/commands/object/object.go +++ b/core/commands/object/object.go @@ -391,9 +391,12 @@ And then run: return err } - _, input, err := req.Files.NextFile() - if err != nil && err != io.EOF { - return err + it, _ := req.Files.Entries() + if !it.Next() && it.Err() != nil { + return it.Err() + } + if it.File() == nil { + return fmt.Errorf("expected a regular file") } inputenc, _ := req.Options["inputenc"].(string) @@ -411,7 +414,7 @@ And then run: return err } - p, err := api.Object().Put(req.Context, input, + p, err := api.Object().Put(req.Context, it.File(), options.Object.DataType(datafieldenc), options.Object.InputEnc(inputenc), options.Object.Pin(dopin)) diff --git a/core/commands/object/patch.go b/core/commands/object/patch.go index 0e8fd8d1160..85f60f0fc1c 100644 --- a/core/commands/object/patch.go +++ b/core/commands/object/patch.go @@ -4,12 +4,12 @@ import ( "fmt" "io" - cmdenv "github.com/ipfs/go-ipfs/core/commands/cmdenv" + "github.com/ipfs/go-ipfs/core/commands/cmdenv" coreiface "github.com/ipfs/go-ipfs/core/coreapi/interface" "github.com/ipfs/go-ipfs/core/coreapi/interface/options" - cmds "gx/ipfs/QmaAP56JAwdjwisPTu4yx17whcjTr6y5JCSCF77Y1rahWV/go-ipfs-cmds" - cmdkit "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit" + "gx/ipfs/QmaAP56JAwdjwisPTu4yx17whcjTr6y5JCSCF77Y1rahWV/go-ipfs-cmds" + "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit" ) var ObjectPatchCmd = &cmds.Command{ @@ -60,12 +60,15 @@ the limit will not be respected by the network. return err } - _, data, err := req.Files.NextFile() - if err != nil { - return err + it, _ := req.Files.Entries() + if !it.Next() && it.Err() != nil { + return it.Err() + } + if it.File() == nil { + return fmt.Errorf("expected a regular file") } - p, err := api.Object().AppendData(req.Context, root, data) + p, err := api.Object().AppendData(req.Context, root, it.File()) if err != nil { return err } @@ -107,12 +110,15 @@ Example: return err } - _, data, err := req.Files.NextFile() - if err != nil { - return err + it, _ := req.Files.Entries() + if !it.Next() && it.Err() != nil { + return it.Err() + } + if it.File() == nil { + return fmt.Errorf("expected a regular file") } - p, err := api.Object().SetData(req.Context, root, data) + p, err := api.Object().SetData(req.Context, root, it.File()) if err != nil { return err } diff --git a/core/commands/tar.go b/core/commands/tar.go index 85e71b3de3c..c03d1c0a941 100644 --- a/core/commands/tar.go +++ b/core/commands/tar.go @@ -44,12 +44,15 @@ represent it. return err } - name, fi, err := req.Files.NextFile() - if err != nil { - return err + it, _ := req.Files.Entries() + if !it.Next() && it.Err() != nil { + return it.Err() + } + if it.File() == nil { + return fmt.Errorf("expected a regular file") } - node, err := tar.ImportTar(req.Context, fi, nd.DAG) + node, err := tar.ImportTar(req.Context, it.File(), nd.DAG) if err != nil { return err } @@ -57,7 +60,7 @@ represent it. c := node.Cid() return cmds.EmitOnce(res, &coreiface.AddEvent{ - Name: name, + Name: it.Name(), Hash: c.String(), }) }, diff --git a/core/coreapi/interface/unixfs.go b/core/coreapi/interface/unixfs.go index 773b36dc039..589083c6b83 100644 --- a/core/coreapi/interface/unixfs.go +++ b/core/coreapi/interface/unixfs.go @@ -23,13 +23,13 @@ type UnixfsAPI interface { // Add imports the data from the reader into merkledag file // // TODO: a long useful comment on how to use this for many different scenarios - Add(context.Context, files.File, ...options.UnixfsAddOption) (ResolvedPath, error) + Add(context.Context, files.Node, ...options.UnixfsAddOption) (ResolvedPath, error) // Get returns a read-only handle to a file tree referenced by a path // // Note that some implementations of this API may apply the specified context // to operations performed on the returned file - Get(context.Context, Path) (files.File, error) + Get(context.Context, Path) (files.Node, error) // Ls returns the list of links in a directory Ls(context.Context, Path) ([]*ipld.Link, error) diff --git a/core/coreapi/unixfile.go b/core/coreapi/unixfile.go index d2ef898871f..f48caa9c5be 100644 --- a/core/coreapi/unixfile.go +++ b/core/coreapi/unixfile.go @@ -3,7 +3,6 @@ package coreapi import ( "context" "errors" - "io" files "gx/ipfs/QmXWZCd8jfaHmt4UDSnjKmGcrQMw95bDGWqEeVLVJjoANX/go-ipfs-files" ft "gx/ipfs/Qmbvw7kpSM2p6rbQ57WGRhhqNfCiNGW6EKH4xgHLw4bsnB/go-unixfs" @@ -21,90 +20,114 @@ const prefetchFiles = 4 type ufsDirectory struct { ctx context.Context dserv ipld.DAGService + dir uio.Directory +} +type ufsIterator struct { + ctx context.Context files chan *ipld.Link + dserv ipld.DAGService + + curName string + curFile files.Node + + err error } -func (d *ufsDirectory) Close() error { - return files.ErrNotReader +func (it *ufsIterator) Name() string { + return it.curName } -func (d *ufsDirectory) Read(_ []byte) (int, error) { - return 0, files.ErrNotReader +func (it *ufsIterator) Node() files.Node { + return it.curFile } -func (d *ufsDirectory) IsDirectory() bool { - return true +func (it *ufsIterator) File() files.File { + f, _ := it.curFile.(files.File) + return f } -func (d *ufsDirectory) NextFile() (string, files.File, error) { - l, ok := <-d.files +func (it *ufsIterator) Dir() files.Directory { + d, _ := it.curFile.(files.Directory) + return d +} + +func (it *ufsIterator) Next() bool { + l, ok := <-it.files if !ok { - return "", nil, io.EOF + return false } - nd, err := l.GetNode(d.ctx, d.dserv) + it.curFile = nil + + nd, err := l.GetNode(it.ctx, it.dserv) if err != nil { - return "", nil, err + it.err = err + return false } - f, err := newUnixfsFile(d.ctx, d.dserv, nd, d) - return l.Name, f, err + it.curName = l.Name + it.curFile, it.err = newUnixfsFile(it.ctx, it.dserv, nd) + return it.err == nil } -func (d *ufsDirectory) Size() (int64, error) { - return 0, files.ErrNotReader +func (it *ufsIterator) Err() error { + return it.err } -func (d *ufsDirectory) Seek(offset int64, whence int) (int64, error) { - return 0, files.ErrNotReader +func (d *ufsDirectory) Close() error { + return nil } -type ufsFile struct { - uio.DagReader +func (d *ufsDirectory) Entries() (files.DirIterator, error) { + fileCh := make(chan *ipld.Link, prefetchFiles) + go func() { + d.dir.ForEachLink(d.ctx, func(link *ipld.Link) error { + select { + case fileCh <- link: + case <-d.ctx.Done(): + return d.ctx.Err() + } + return nil + }) + + close(fileCh) + }() + + return &ufsIterator{ + ctx: d.ctx, + files: fileCh, + dserv: d.dserv, + }, nil } -func (f *ufsFile) IsDirectory() bool { - return false +func (d *ufsDirectory) Size() (int64, error) { + return 0, files.ErrNotSupported } -func (f *ufsFile) NextFile() (string, files.File, error) { - return "", nil, files.ErrNotDirectory +type ufsFile struct { + uio.DagReader } func (f *ufsFile) Size() (int64, error) { return int64(f.DagReader.Size()), nil } -func newUnixfsDir(ctx context.Context, dserv ipld.DAGService, nd ipld.Node) (files.File, error) { +func newUnixfsDir(ctx context.Context, dserv ipld.DAGService, nd ipld.Node) (files.Directory, error) { dir, err := uio.NewDirectoryFromNode(dserv, nd) if err != nil { return nil, err } - fileCh := make(chan *ipld.Link, prefetchFiles) - go func() { - dir.ForEachLink(ctx, func(link *ipld.Link) error { - select { - case fileCh <- link: - case <-ctx.Done(): - return ctx.Err() - } - return nil - }) - - close(fileCh) - }() - return &ufsDirectory{ ctx: ctx, dserv: dserv, - files: fileCh, + dir: dir, }, nil } -func newUnixfsFile(ctx context.Context, dserv ipld.DAGService, nd ipld.Node, parent files.File) (files.File, error) { +func newUnixfsFile(ctx context.Context, dserv ipld.DAGService, nd ipld.Node) (files.Node, error) { switch dn := nd.(type) { case *dag.ProtoNode: fsn, err := ft.FSNodeFromBytes(dn.Data()) @@ -129,3 +152,6 @@ func newUnixfsFile(ctx context.Context, dserv ipld.DAGService, nd ipld.Node, par DagReader: dr, }, nil } + +var _ files.Directory = &ufsDirectory{} +var _ files.File = &ufsFile{} diff --git a/core/coreapi/unixfs.go b/core/coreapi/unixfs.go index f3c5038caf7..27341c9277c 100644 --- a/core/coreapi/unixfs.go +++ b/core/coreapi/unixfs.go @@ -28,7 +28,7 @@ type UnixfsAPI CoreAPI // Add builds a merkledag node from a reader, adds it to the blockstore, // and returns the key representing that node. -func (api *UnixfsAPI) Add(ctx context.Context, files files.File, opts ...options.UnixfsAddOption) (coreiface.ResolvedPath, error) { +func (api *UnixfsAPI) Add(ctx context.Context, files files.Node, opts ...options.UnixfsAddOption) (coreiface.ResolvedPath, error) { settings, prefix, err := options.UnixfsAddOptions(opts...) if err != nil { return nil, err @@ -133,7 +133,7 @@ func (api *UnixfsAPI) Add(ctx context.Context, files files.File, opts ...options return coreiface.IpfsPath(nd.Cid()), nil } -func (api *UnixfsAPI) Get(ctx context.Context, p coreiface.Path) (files.File, error) { +func (api *UnixfsAPI) Get(ctx context.Context, p coreiface.Path) (files.Node, error) { ses := api.core().getSession(ctx) nd, err := ses.ResolveNode(ctx, p) @@ -141,7 +141,7 @@ func (api *UnixfsAPI) Get(ctx context.Context, p coreiface.Path) (files.File, er return nil, err } - return newUnixfsFile(ctx, ses.dag, nd, nil) + return newUnixfsFile(ctx, ses.dag, nd) } // Ls returns the contents of an IPFS or IPNS object(s) at path p, with the format: diff --git a/core/coreapi/unixfs_test.go b/core/coreapi/unixfs_test.go index 8b773dd96d2..55b7aa862f7 100644 --- a/core/coreapi/unixfs_test.go +++ b/core/coreapi/unixfs_test.go @@ -134,36 +134,36 @@ func makeAPI(ctx context.Context) (*core.IpfsNode, coreiface.CoreAPI, error) { return nd[0], api[0], nil } -func strFile(data string) func() files.File { - return func() files.File { +func strFile(data string) func() files.Node { + return func() files.Node { return files.NewReaderFile(ioutil.NopCloser(strings.NewReader(data)), nil) } } -func twoLevelDir() func() files.File { - return func() files.File { - return files.NewSliceFile([]files.FileEntry{{ - Name: "abc", File: files.NewSliceFile([]files.FileEntry{ - {Name: "def", File: files.NewReaderFile(ioutil.NopCloser(strings.NewReader("world")), nil)}, - })}, +func twoLevelDir() func() files.Node { + return func() files.Node { + return files.NewSliceFile([]files.DirEntry{ + files.FileEntry("abc", files.NewSliceFile([]files.DirEntry{ + files.FileEntry("def", files.NewReaderFile(ioutil.NopCloser(strings.NewReader("world")), nil)), + })), - {Name: "bar", File: files.NewReaderFile(ioutil.NopCloser(strings.NewReader("hello2")), nil)}, - {Name: "foo", File: files.NewReaderFile(ioutil.NopCloser(strings.NewReader("hello1")), nil)}, + files.FileEntry("bar", files.NewReaderFile(ioutil.NopCloser(strings.NewReader("hello2")), nil)), + files.FileEntry("foo", files.NewReaderFile(ioutil.NopCloser(strings.NewReader("hello1")), nil)), }) } } -func flatDir() files.File { - return files.NewSliceFile([]files.FileEntry{ - {Name: "bar", File: files.NewReaderFile(ioutil.NopCloser(strings.NewReader("hello2")), nil)}, - {Name: "foo", File: files.NewReaderFile(ioutil.NopCloser(strings.NewReader("hello1")), nil)}, +func flatDir() files.Node { + return files.NewSliceFile([]files.DirEntry{ + files.FileEntry("bar", files.NewReaderFile(ioutil.NopCloser(strings.NewReader("hello2")), nil)), + files.FileEntry("foo", files.NewReaderFile(ioutil.NopCloser(strings.NewReader("hello1")), nil)), }) } -func wrapped(name string) func(f files.File) files.File { - return func(f files.File) files.File { - return files.NewSliceFile([]files.FileEntry{ - {Name: name, File: f}, +func wrapped(name string) func(f files.Node) files.Node { + return func(f files.Node) files.Node { + return files.NewSliceFile([]files.DirEntry{ + files.FileEntry(name, f), }) } } @@ -177,8 +177,8 @@ func TestAdd(t *testing.T) { cases := []struct { name string - data func() files.File - expect func(files.File) files.File + data func() files.Node + expect func(files.Node) files.Node path string err string @@ -295,7 +295,7 @@ func TestAdd(t *testing.T) { { name: "addWrapped", path: "/ipfs/QmVE9rNpj5doj7XHzp5zMUxD7BJgXEqx4pe3xZ3JBReWHE", - data: func() files.File { + data: func() files.Node { return files.NewReaderFile(ioutil.NopCloser(strings.NewReader(helloStr)), nil) }, wrap: "foo", @@ -305,7 +305,7 @@ func TestAdd(t *testing.T) { { name: "addNotWrappedDirFile", path: hello, - data: func() files.File { + data: func() files.Node { return files.NewReaderFile(ioutil.NopCloser(strings.NewReader(helloStr)), nil) }, wrap: "foo", @@ -313,12 +313,12 @@ func TestAdd(t *testing.T) { { name: "stdinWrapped", path: "/ipfs/QmU3r81oZycjHS9oaSHw37ootMFuFUw1DvMLKXPsezdtqU", - data: func() files.File { + data: func() files.Node { return files.NewReaderFile(ioutil.NopCloser(strings.NewReader(helloStr)), nil) }, - expect: func(files.File) files.File { - return files.NewSliceFile([]files.FileEntry{ - {Name: "QmQy2Dw4Wk7rdJKjThjYXzfFJNaRKRHhHP5gHHXroJMYxk", File: files.NewReaderFile(ioutil.NopCloser(strings.NewReader(helloStr)), nil)}, + expect: func(files.Node) files.Node { + return files.NewSliceFile([]files.DirEntry{ + files.FileEntry("QmQy2Dw4Wk7rdJKjThjYXzfFJNaRKRHhHP5gHHXroJMYxk", files.NewReaderFile(ioutil.NopCloser(strings.NewReader(helloStr)), nil)), }) }, opts: []options.UnixfsAddOption{options.Unixfs.Wrap(true)}, @@ -326,7 +326,7 @@ func TestAdd(t *testing.T) { { name: "stdinNamed", path: "/ipfs/QmQ6cGBmb3ZbdrQW1MRm1RJnYnaxCqfssz7CrTa9NEhQyS", - data: func() files.File { + data: func() files.Node { rf, err := files.NewReaderPathFile(os.Stdin.Name(), ioutil.NopCloser(strings.NewReader(helloStr)), nil) if err != nil { panic(err) @@ -334,9 +334,9 @@ func TestAdd(t *testing.T) { return rf }, - expect: func(files.File) files.File { - return files.NewSliceFile([]files.FileEntry{ - {Name: "test", File: files.NewReaderFile(ioutil.NopCloser(strings.NewReader(helloStr)), nil)}, + expect: func(files.Node) files.Node { + return files.NewSliceFile([]files.DirEntry{ + files.FileEntry("test", files.NewReaderFile(ioutil.NopCloser(strings.NewReader(helloStr)), nil)), }) }, opts: []options.UnixfsAddOption{options.Unixfs.Wrap(true), options.Unixfs.StdinName("test")}, @@ -360,11 +360,11 @@ func TestAdd(t *testing.T) { // hidden { name: "hiddenFiles", - data: func() files.File { - return files.NewSliceFile([]files.FileEntry{ - {Name: ".bar", File: files.NewReaderFile(ioutil.NopCloser(strings.NewReader("hello2")), nil)}, - {Name: "bar", File: files.NewReaderFile(ioutil.NopCloser(strings.NewReader("hello2")), nil)}, - {Name: "foo", File: files.NewReaderFile(ioutil.NopCloser(strings.NewReader("hello1")), nil)}, + data: func() files.Node { + return files.NewSliceFile([]files.DirEntry{ + files.FileEntry(".bar", files.NewReaderFile(ioutil.NopCloser(strings.NewReader("hello2")), nil)), + files.FileEntry("bar", files.NewReaderFile(ioutil.NopCloser(strings.NewReader("hello2")), nil)), + files.FileEntry("foo", files.NewReaderFile(ioutil.NopCloser(strings.NewReader("hello1")), nil)), }) }, wrap: "t", @@ -373,7 +373,7 @@ func TestAdd(t *testing.T) { }, { name: "hiddenFileAlwaysAdded", - data: func() files.File { + data: func() files.Node { return files.NewReaderFile(ioutil.NopCloser(strings.NewReader(helloStr)), nil) }, wrap: ".foo", @@ -381,14 +381,14 @@ func TestAdd(t *testing.T) { }, { name: "hiddenFilesNotAdded", - data: func() files.File { - return files.NewSliceFile([]files.FileEntry{ - {Name: ".bar", File: files.NewReaderFile(ioutil.NopCloser(strings.NewReader("hello2")), nil)}, - {Name: "bar", File: files.NewReaderFile(ioutil.NopCloser(strings.NewReader("hello2")), nil)}, - {Name: "foo", File: files.NewReaderFile(ioutil.NopCloser(strings.NewReader("hello1")), nil)}, + data: func() files.Node { + return files.NewSliceFile([]files.DirEntry{ + files.FileEntry(".bar", files.NewReaderFile(ioutil.NopCloser(strings.NewReader("hello2")), nil)), + files.FileEntry("bar", files.NewReaderFile(ioutil.NopCloser(strings.NewReader("hello2")), nil)), + files.FileEntry("foo", files.NewReaderFile(ioutil.NopCloser(strings.NewReader("hello1")), nil)), }) }, - expect: func(files.File) files.File { + expect: func(files.Node) files.Node { return flatDir() }, wrap: "t", @@ -431,7 +431,7 @@ func TestAdd(t *testing.T) { }, { name: "progress1M", - data: func() files.File { + data: func() files.Node { r := bytes.NewReader(bytes.Repeat([]byte{0}, 1000000)) return files.NewReaderFile(ioutil.NopCloser(r), nil) }, @@ -457,8 +457,8 @@ func TestAdd(t *testing.T) { data := testCase.data() if testCase.wrap != "" { - data = files.NewSliceFile([]files.FileEntry{ - {Name: testCase.wrap, File: data}, + data = files.NewSliceFile([]files.DirEntry{ + files.FileEntry(testCase.wrap, data), }) } @@ -533,9 +533,12 @@ func TestAdd(t *testing.T) { // compare file structure with Unixfs().Get - var cmpFile func(origName string, orig files.File, gotName string, got files.File) - cmpFile = func(origName string, orig files.File, gotName string, got files.File) { - if orig.IsDirectory() != got.IsDirectory() { + var cmpFile func(origName string, orig files.Node, gotName string, got files.Node) + cmpFile = func(origName string, orig files.Node, gotName string, got files.Node) { + _, origDir := orig.(files.Directory) + _, gotDir := got.(files.Directory) + + if origDir != gotDir { t.Fatal("file type mismatch") } @@ -543,16 +546,16 @@ func TestAdd(t *testing.T) { t.Errorf("file name mismatch, orig='%s', got='%s'", origName, gotName) } - if !orig.IsDirectory() { + if !gotDir { defer orig.Close() defer got.Close() - do, err := ioutil.ReadAll(orig) + do, err := ioutil.ReadAll(orig.(files.File)) if err != nil { t.Fatal(err) } - dg, err := ioutil.ReadAll(got) + dg, err := ioutil.ReadAll(got.(files.File)) if err != nil { t.Fatal(err) } @@ -564,21 +567,28 @@ func TestAdd(t *testing.T) { return } - for { - origName, origFile, err := orig.NextFile() - gotName, gotFile, err2 := got.NextFile() + origIt, _ := orig.(files.Directory).Entries() + gotIt, _ := got.(files.Directory).Entries() - if err != nil { - if err == io.EOF && err2 == io.EOF { - break + for { + if origIt.Next() { + if !gotIt.Next() { + t.Fatal("gotIt out of entries before origIt") } - t.Fatal(err) - } - if err2 != nil { - t.Fatal(err) + } else { + if gotIt.Next() { + t.Fatal("origIt out of entries before gotIt") + } + break } - cmpFile(origName, origFile, gotName, gotFile) + cmpFile(origIt.Name(), origIt.Node(), gotIt.Name(), gotIt.Node()) + } + if origIt.Err() != nil { + t.Fatal(origIt.Err()) + } + if gotIt.Err() != nil { + t.Fatal(gotIt.Err()) } } @@ -667,7 +677,7 @@ func TestGetEmptyFile(t *testing.T) { } buf := make([]byte, 1) // non-zero so that Read() actually tries to read - n, err := io.ReadFull(r, buf) + n, err := io.ReadFull(r.(files.File), buf) if err != nil && err != io.EOF { t.Error(err) } @@ -703,9 +713,8 @@ func TestGetDir(t *testing.T) { t.Error(err) } - _, err = r.Read(make([]byte, 2)) - if err != files.ErrNotReader { - t.Fatalf("expected ErrIsDir, got: %s", err) + if _, ok := r.(files.Directory); !ok { + t.Fatalf("expected a directory") } } diff --git a/core/corehttp/gateway_handler.go b/core/corehttp/gateway_handler.go index 103916c7783..e0330185e16 100644 --- a/core/corehttp/gateway_handler.go +++ b/core/corehttp/gateway_handler.go @@ -172,10 +172,7 @@ func (i *gatewayHandler) getOrHeadHandler(ctx context.Context, w http.ResponseWr return } - dir := dr.IsDirectory() - if !dir { - defer dr.Close() - } + defer dr.Close() // Check etag send back to us etag := "\"" + resolvedPath.Cid().String() + "\"" @@ -240,14 +237,14 @@ func (i *gatewayHandler) getOrHeadHandler(ctx context.Context, w http.ResponseWr // TODO: break this out when we split /ipfs /ipns routes. modtime := time.Now() - if strings.HasPrefix(urlPath, ipfsPathPrefix) && !dir { - w.Header().Set("Cache-Control", "public, max-age=29030400, immutable") + if f, ok := dr.(files.File); ok { + if strings.HasPrefix(urlPath, ipfsPathPrefix) { + w.Header().Set("Cache-Control", "public, max-age=29030400, immutable") - // set modtime to a really long time ago, since files are immutable and should stay cached - modtime = time.Unix(1, 0) - } + // set modtime to a really long time ago, since files are immutable and should stay cached + modtime = time.Unix(1, 0) + } - if !dir { urlFilename := r.URL.Query().Get("filename") var name string if urlFilename != "" { @@ -256,8 +253,9 @@ func (i *gatewayHandler) getOrHeadHandler(ctx context.Context, w http.ResponseWr } else { name = getFilename(urlPath) } - i.serveFile(w, r, name, modtime, dr) + i.serveFile(w, r, name, modtime, f) return + } nd, err := i.api.ResolveNode(ctx, resolvedPath) @@ -290,8 +288,14 @@ func (i *gatewayHandler) getOrHeadHandler(ctx context.Context, w http.ResponseWr } defer dr.Close() + f, ok := dr.(files.File) + if !ok { + internalWebError(w, files.ErrNotReader) + return + } + // write to request - http.ServeContent(w, r, "index.html", modtime, dr) + http.ServeContent(w, r, "index.html", modtime, f) return default: internalWebError(w, err) diff --git a/core/coreunix/add.go b/core/coreunix/add.go index fcfa4aa6e10..66a0ed1d6db 100644 --- a/core/coreunix/add.go +++ b/core/coreunix/add.go @@ -2,6 +2,7 @@ package coreunix import ( "context" + "errors" "fmt" "io" "io/ioutil" @@ -400,7 +401,7 @@ func (adder *Adder) addNode(node ipld.Node, path string) error { } // AddAllAndPin adds the given request's files and pin them. -func (adder *Adder) AddAllAndPin(file files.File) (ipld.Node, error) { +func (adder *Adder) AddAllAndPin(file files.Node) (ipld.Node, error) { if adder.Pin { adder.unlocker = adder.blockstore.PinLock() } @@ -410,23 +411,23 @@ func (adder *Adder) AddAllAndPin(file files.File) (ipld.Node, error) { } }() - switch { - case file.IsDirectory(): + switch tf := file.(type) { + case files.Directory: // Iterate over each top-level file and add individually. Otherwise the // single files.File f is treated as a directory, affecting hidden file // semantics. - for { - name, f, err := file.NextFile() - if err == io.EOF { - // Finished the list of files. - break - } else if err != nil { - return nil, err - } - if err := adder.addFile(name, f); err != nil { + it, err := tf.Entries() + if err != nil { + return nil, err + } + for it.Next() { + if err := adder.addFile(it.Name(), it.Node()); err != nil { return nil, err } } + if it.Err() != nil { + return nil, it.Err() + } break default: if err := adder.addFile("", file); err != nil { @@ -447,7 +448,7 @@ func (adder *Adder) AddAllAndPin(file files.File) (ipld.Node, error) { return nd, adder.PinRoot() } -func (adder *Adder) addFile(path string, file files.File) error { +func (adder *Adder) addFile(path string, file files.Node) error { err := adder.maybePauseForGC() if err != nil { return err @@ -467,8 +468,8 @@ func (adder *Adder) addFile(path string, file files.File) error { } adder.liveNodes++ - if file.IsDirectory() { - return adder.addDir(path, file) + if dir, ok := file.(files.Directory); ok { + return adder.addDir(path, dir) } // case for symlink @@ -491,9 +492,12 @@ func (adder *Adder) addFile(path string, file files.File) error { // case for regular file // if the progress flag was specified, wrap the file so that we can send // progress updates to the client (over the output channel) - var reader io.Reader = file + reader, ok := file.(io.Reader) + if !ok { + return errors.New("file doesn't support reading") + } if adder.Progress { - rdr := &progressReader{file: file, path: path, out: adder.Out} + rdr := &progressReader{file: reader, path: path, out: adder.Out} if fi, ok := file.(files.FileInfo); ok { reader = &progressReader2{rdr, fi} } else { @@ -517,7 +521,7 @@ func (adder *Adder) addFile(path string, file files.File) error { return adder.addNode(dagnode, path) } -func (adder *Adder) addDir(path string, dir files.File) error { +func (adder *Adder) addDir(path string, dir files.Directory) error { log.Infof("adding directory: %s", path) mr, err := adder.mfsRoot() @@ -533,27 +537,23 @@ func (adder *Adder) addDir(path string, dir files.File) error { return err } - for { - name, file, err := dir.NextFile() - if err != nil && err != io.EOF { - return err - } - if file == nil { - break - } - - fpath := gopath.Join(path, name) + it, _ := dir.Entries() + for it.Next() { + fpath := gopath.Join(path, it.Name()) // Skip hidden files when adding recursively, unless Hidden is enabled. - if files.IsHidden(fpath, file) && !adder.Hidden { + if files.IsHidden(fpath, it.Node()) && !adder.Hidden { log.Infof("%s is hidden, skipping", fpath) continue } - err = adder.addFile(fpath, file) + err = adder.addFile(fpath, it.Node()) if err != nil { return err } } + if it.Err() != nil { + return it.Err() + } return nil } @@ -616,7 +616,7 @@ func getOutput(dagnode ipld.Node) (*Object, error) { } type progressReader struct { - file files.File + file io.Reader path string out chan<- interface{} bytes int64 diff --git a/core/coreunix/add_test.go b/core/coreunix/add_test.go index b1f5be3c93a..fe9e1e0d66f 100644 --- a/core/coreunix/add_test.go +++ b/core/coreunix/add_test.go @@ -81,10 +81,10 @@ func TestAddGCLive(t *testing.T) { datad := ioutil.NopCloser(bytes.NewBufferString("testfileD")) rfd := files.NewReaderFile(datad, nil) - slf := files.NewSliceFile([]files.FileEntry{ - {File: rfa, Name: "a"}, - {File: hangfile, Name: "b"}, - {File: rfd, Name: "d"}, + slf := files.NewSliceFile([]files.DirEntry{ + files.FileEntry("a", rfa), + files.FileEntry("b", hangfile), + files.FileEntry("d", rfd), }) addDone := make(chan struct{}) diff --git a/fuse/readonly/ipfs_test.go b/fuse/readonly/ipfs_test.go index dea91b65359..8a02d68d1d1 100644 --- a/fuse/readonly/ipfs_test.go +++ b/fuse/readonly/ipfs_test.go @@ -22,6 +22,7 @@ import ( ci "gx/ipfs/QmPuhRE325DR8ChNcFtgd6F1eANCHy1oohXZPpYop4xsK6/go-testutil/ci" chunker "gx/ipfs/QmR4QQVkBZsZENRjYFVi8dEtPL3daZRNKk24m4r6WKJHNm/go-ipfs-chunker" fstest "gx/ipfs/QmSJBsmLP1XMjv8hxYg2rUMdPDB7YUpyBo9idjrJ6Cmq6F/fuse/fs/fstestutil" + files "gx/ipfs/QmXWZCd8jfaHmt4UDSnjKmGcrQMw95bDGWqEeVLVJjoANX/go-ipfs-files" importer "gx/ipfs/Qmbvw7kpSM2p6rbQ57WGRhhqNfCiNGW6EKH4xgHLw4bsnB/go-unixfs/importer" uio "gx/ipfs/Qmbvw7kpSM2p6rbQ57WGRhhqNfCiNGW6EKH4xgHLw4bsnB/go-unixfs/io" ipld "gx/ipfs/QmcKKBwfz6FyQdHR2jsXrrF6XeSBXYL86anmWNewpFpoF5/go-ipld-format" @@ -180,7 +181,7 @@ func TestIpfsStressRead(t *testing.T) { errs <- err } - data, err := ioutil.ReadAll(read) + data, err := ioutil.ReadAll(read.(files.File)) if err != nil { errs <- err } diff --git a/test/integration/addcat_test.go b/test/integration/addcat_test.go index 177d2c5ee6d..0d8a200737e 100644 --- a/test/integration/addcat_test.go +++ b/test/integration/addcat_test.go @@ -154,7 +154,7 @@ func DirectAddCat(data []byte, conf testutil.LatencyConfig) error { // verify bufout := new(bytes.Buffer) - io.Copy(bufout, readerCatted) + io.Copy(bufout, readerCatted.(io.Reader)) if 0 != bytes.Compare(bufout.Bytes(), data) { return errors.New("catted data does not match added data") } diff --git a/test/integration/bench_cat_test.go b/test/integration/bench_cat_test.go index 6ff8f56ba9d..d228e45a19b 100644 --- a/test/integration/bench_cat_test.go +++ b/test/integration/bench_cat_test.go @@ -101,7 +101,7 @@ func benchCat(b *testing.B, data []byte, conf testutil.LatencyConfig) error { // verify bufout := new(bytes.Buffer) - io.Copy(bufout, readerCatted) + io.Copy(bufout, readerCatted.(io.Reader)) if 0 != bytes.Compare(bufout.Bytes(), data) { return errors.New("catted data does not match added data") } diff --git a/test/integration/three_legged_cat_test.go b/test/integration/three_legged_cat_test.go index 3fca20aa75e..200c584e39f 100644 --- a/test/integration/three_legged_cat_test.go +++ b/test/integration/three_legged_cat_test.go @@ -133,7 +133,7 @@ func RunThreeLeggedCat(data []byte, conf testutil.LatencyConfig) error { // verify bufout := new(bytes.Buffer) - io.Copy(bufout, readerCatted) + io.Copy(bufout, readerCatted.(io.Reader)) if 0 != bytes.Compare(bufout.Bytes(), data) { return errors.New("catted data does not match added data") } From b10e718ab4e032cdc806ca4903c5910cd51099db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Sat, 24 Nov 2018 04:51:43 +0100 Subject: [PATCH 07/16] files2.0: no error from Entries MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit License: MIT Signed-off-by: Łukasz Magiera --- cmd/ipfs/init.go | 2 +- core/commands/block.go | 2 +- core/commands/config.go | 2 +- core/commands/dag/dag.go | 2 +- core/commands/files.go | 2 +- core/commands/object/object.go | 2 +- core/commands/object/patch.go | 4 ++-- core/commands/tar.go | 2 +- core/coreapi/unixfile.go | 4 ++-- core/coreapi/unixfs_test.go | 4 ++-- core/coreunix/add.go | 7 ++----- 11 files changed, 15 insertions(+), 18 deletions(-) diff --git a/cmd/ipfs/init.go b/cmd/ipfs/init.go index 9dc4f7fb806..e78b3658420 100644 --- a/cmd/ipfs/init.go +++ b/cmd/ipfs/init.go @@ -85,7 +85,7 @@ environment variable: f := req.Files if f != nil { - it, _ := req.Files.Entries() + it := req.Files.Entries() if !it.Next() && it.Err() != nil { return it.Err() } diff --git a/core/commands/block.go b/core/commands/block.go index b50f4c141ee..670056098f9 100644 --- a/core/commands/block.go +++ b/core/commands/block.go @@ -153,7 +153,7 @@ than 'sha2-256' or format to anything other than 'v0' will result in CIDv1. return err } - it, _ := req.Files.Entries() + it := req.Files.Entries() if !it.Next() && it.Err() != nil { return it.Err() } diff --git a/core/commands/config.go b/core/commands/config.go index e2fc32b0cfa..787bba0d7cd 100644 --- a/core/commands/config.go +++ b/core/commands/config.go @@ -280,7 +280,7 @@ can't be undone. } defer r.Close() - it, _ := req.Files.Entries() + it := req.Files.Entries() if !it.Next() && it.Err() != nil { return it.Err() } diff --git a/core/commands/dag/dag.go b/core/commands/dag/dag.go index 0da4af91a71..413f26bc7b4 100644 --- a/core/commands/dag/dag.go +++ b/core/commands/dag/dag.go @@ -92,7 +92,7 @@ into an object of the specified format. defer nd.Blockstore.PinLock().Unlock() } - it, _ := req.Files.Entries() + it := req.Files.Entries() for it.Next() { if it.File() == nil { return fmt.Errorf("expected a regular file") diff --git a/core/commands/files.go b/core/commands/files.go index 2792bad9844..20fce2bfc9f 100644 --- a/core/commands/files.go +++ b/core/commands/files.go @@ -769,7 +769,7 @@ stat' on the file or any of its ancestors. return err } - it, _ := req.Files.Entries() + it := req.Files.Entries() if !it.Next() && it.Err() != nil { return it.Err() } diff --git a/core/commands/object/object.go b/core/commands/object/object.go index c21a193e220..b3ccc3b725a 100644 --- a/core/commands/object/object.go +++ b/core/commands/object/object.go @@ -391,7 +391,7 @@ And then run: return err } - it, _ := req.Files.Entries() + it := req.Files.Entries() if !it.Next() && it.Err() != nil { return it.Err() } diff --git a/core/commands/object/patch.go b/core/commands/object/patch.go index 85f60f0fc1c..058fa661a83 100644 --- a/core/commands/object/patch.go +++ b/core/commands/object/patch.go @@ -60,7 +60,7 @@ the limit will not be respected by the network. return err } - it, _ := req.Files.Entries() + it := req.Files.Entries() if !it.Next() && it.Err() != nil { return it.Err() } @@ -110,7 +110,7 @@ Example: return err } - it, _ := req.Files.Entries() + it := req.Files.Entries() if !it.Next() && it.Err() != nil { return it.Err() } diff --git a/core/commands/tar.go b/core/commands/tar.go index c03d1c0a941..92939a1eb37 100644 --- a/core/commands/tar.go +++ b/core/commands/tar.go @@ -44,7 +44,7 @@ represent it. return err } - it, _ := req.Files.Entries() + it := req.Files.Entries() if !it.Next() && it.Err() != nil { return it.Err() } diff --git a/core/coreapi/unixfile.go b/core/coreapi/unixfile.go index f48caa9c5be..1ec15ea3734 100644 --- a/core/coreapi/unixfile.go +++ b/core/coreapi/unixfile.go @@ -79,7 +79,7 @@ func (d *ufsDirectory) Close() error { return nil } -func (d *ufsDirectory) Entries() (files.DirIterator, error) { +func (d *ufsDirectory) Entries() files.DirIterator { fileCh := make(chan *ipld.Link, prefetchFiles) go func() { d.dir.ForEachLink(d.ctx, func(link *ipld.Link) error { @@ -98,7 +98,7 @@ func (d *ufsDirectory) Entries() (files.DirIterator, error) { ctx: d.ctx, files: fileCh, dserv: d.dserv, - }, nil + } } func (d *ufsDirectory) Size() (int64, error) { diff --git a/core/coreapi/unixfs_test.go b/core/coreapi/unixfs_test.go index 55b7aa862f7..0ce78665cd8 100644 --- a/core/coreapi/unixfs_test.go +++ b/core/coreapi/unixfs_test.go @@ -567,8 +567,8 @@ func TestAdd(t *testing.T) { return } - origIt, _ := orig.(files.Directory).Entries() - gotIt, _ := got.(files.Directory).Entries() + origIt := orig.(files.Directory).Entries() + gotIt := got.(files.Directory).Entries() for { if origIt.Next() { diff --git a/core/coreunix/add.go b/core/coreunix/add.go index 66a0ed1d6db..2e2641d4e19 100644 --- a/core/coreunix/add.go +++ b/core/coreunix/add.go @@ -416,10 +416,7 @@ func (adder *Adder) AddAllAndPin(file files.Node) (ipld.Node, error) { // Iterate over each top-level file and add individually. Otherwise the // single files.File f is treated as a directory, affecting hidden file // semantics. - it, err := tf.Entries() - if err != nil { - return nil, err - } + it := tf.Entries() for it.Next() { if err := adder.addFile(it.Name(), it.Node()); err != nil { return nil, err @@ -537,7 +534,7 @@ func (adder *Adder) addDir(path string, dir files.Directory) error { return err } - it, _ := dir.Entries() + it := dir.Entries() for it.Next() { fpath := gopath.Join(path, it.Name()) From 5ff5e48fbe0fe95171cbff3f8289187e24fe3a75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Thu, 29 Nov 2018 18:54:46 +0100 Subject: [PATCH 08/16] files2.0: return the right error in dag put MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit License: MIT Signed-off-by: Łukasz Magiera --- core/commands/dag/dag.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/commands/dag/dag.go b/core/commands/dag/dag.go index 413f26bc7b4..21714630fe2 100644 --- a/core/commands/dag/dag.go +++ b/core/commands/dag/dag.go @@ -119,7 +119,7 @@ into an object of the specified format. } } if it.Err() != nil { - return err + return it.Err() } if err := b.Commit(); err != nil { From eb1ecf878984cfd1169474f8ed0ef3260094ca01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Sat, 1 Dec 2018 00:44:31 +0100 Subject: [PATCH 09/16] files2.0: more regreussion fixes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit License: MIT Signed-off-by: Łukasz Magiera --- test/sharness/t0040-add-and-cat.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/sharness/t0040-add-and-cat.sh b/test/sharness/t0040-add-and-cat.sh index 134eb6354a8..e16fb57c4ca 100755 --- a/test/sharness/t0040-add-and-cat.sh +++ b/test/sharness/t0040-add-and-cat.sh @@ -413,7 +413,7 @@ test_add_named_pipe() { test_expect_code 1 ipfs add named-pipe 2>actual && STAT=$(generic_stat named-pipe) && rm named-pipe && - grep "Error: Unrecognized file type for named-pipe: $STAT" actual && + grep "Error: unrecognized file type for named-pipe: $STAT" actual && grep USAGE actual && grep "ipfs add" actual ' @@ -423,7 +423,7 @@ test_add_named_pipe() { mkfifo named-pipe-dir/named-pipe && STAT=$(generic_stat named-pipe-dir/named-pipe) && test_expect_code 1 ipfs add -r named-pipe-dir 2>actual && - printf "Error:$err_prefix Unrecognized file type for named-pipe-dir/named-pipe: $STAT\n" >expected && + printf "Error:$err_prefix unrecognized file type for named-pipe-dir/named-pipe: $STAT\n" >expected && rm named-pipe-dir/named-pipe && rmdir named-pipe-dir && test_cmp expected actual From b85ecb848ae5ac07759d9ebc8745d68fd1ac8c4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Mon, 3 Dec 2018 21:24:36 +0100 Subject: [PATCH 10/16] files2.0: Use new type helpers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit License: MIT Signed-off-by: Łukasz Magiera --- cmd/ipfs/init.go | 5 +-- core/commands/block.go | 5 +-- core/commands/config.go | 5 +-- core/commands/dag/dag.go | 5 +-- core/commands/files.go | 5 +-- core/commands/object/object.go | 5 +-- core/commands/object/patch.go | 9 +++--- core/commands/tar.go | 5 +-- core/coreapi/name_test.go | 3 +- core/coreapi/unixfile.go | 10 ------ core/coreapi/unixfs_test.go | 59 +++++++++++++++++----------------- core/coreunix/add_test.go | 16 ++++----- 12 files changed, 63 insertions(+), 69 deletions(-) diff --git a/cmd/ipfs/init.go b/cmd/ipfs/init.go index e78b3658420..2ee7488ac3a 100644 --- a/cmd/ipfs/init.go +++ b/cmd/ipfs/init.go @@ -19,6 +19,7 @@ import ( "gx/ipfs/QmYyzmMnhNTtoXx5ttgUaRdHHckYnQWjPL98hgLAR2QLDD/go-ipfs-config" "gx/ipfs/QmaAP56JAwdjwisPTu4yx17whcjTr6y5JCSCF77Y1rahWV/go-ipfs-cmds" "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit" + "gx/ipfs/QmeaQRmnRog7NxLEWHP9zSTkics4cbgwBVa7q49LmBowDr/go-ipfs-files" ) const ( @@ -89,12 +90,12 @@ environment variable: if !it.Next() && it.Err() != nil { return it.Err() } - if it.File() == nil { + if files.FileFrom(it) == nil { return fmt.Errorf("expected a regular file") } conf = &config.Config{} - if err := json.NewDecoder(it.File()).Decode(conf); err != nil { + if err := json.NewDecoder(files.FileFrom(it)).Decode(conf); err != nil { return err } } diff --git a/core/commands/block.go b/core/commands/block.go index 670056098f9..ec7f6baf42e 100644 --- a/core/commands/block.go +++ b/core/commands/block.go @@ -13,6 +13,7 @@ import ( cmds "gx/ipfs/QmaAP56JAwdjwisPTu4yx17whcjTr6y5JCSCF77Y1rahWV/go-ipfs-cmds" cmdkit "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit" + files "gx/ipfs/QmeaQRmnRog7NxLEWHP9zSTkics4cbgwBVa7q49LmBowDr/go-ipfs-files" mh "gx/ipfs/QmerPMzPk1mJVowm8KgmoknWa4yCYvvugMPsgWmDNUvDLW/go-multihash" ) @@ -157,7 +158,7 @@ than 'sha2-256' or format to anything other than 'v0' will result in CIDv1. if !it.Next() && it.Err() != nil { return it.Err() } - if it.File() == nil { + if files.FileFrom(it) == nil { return fmt.Errorf("expected a regular file") } @@ -181,7 +182,7 @@ than 'sha2-256' or format to anything other than 'v0' will result in CIDv1. } } - p, err := api.Block().Put(req.Context, it.File(), options.Block.Hash(mhtval, mhlen), options.Block.Format(format)) + p, err := api.Block().Put(req.Context, files.FileFrom(it), options.Block.Hash(mhtval, mhlen), options.Block.Format(format)) if err != nil { return err } diff --git a/core/commands/config.go b/core/commands/config.go index 787bba0d7cd..ad6f6f30eb8 100644 --- a/core/commands/config.go +++ b/core/commands/config.go @@ -18,6 +18,7 @@ import ( config "gx/ipfs/QmYyzmMnhNTtoXx5ttgUaRdHHckYnQWjPL98hgLAR2QLDD/go-ipfs-config" cmds "gx/ipfs/QmaAP56JAwdjwisPTu4yx17whcjTr6y5JCSCF77Y1rahWV/go-ipfs-cmds" cmdkit "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit" + files "gx/ipfs/QmeaQRmnRog7NxLEWHP9zSTkics4cbgwBVa7q49LmBowDr/go-ipfs-files" ) // ConfigUpdateOutput is config profile apply command's output @@ -284,10 +285,10 @@ can't be undone. if !it.Next() && it.Err() != nil { return it.Err() } - if it.File() == nil { + if files.FileFrom(it) == nil { return fmt.Errorf("expected a regular file") } - file := it.File() + file := files.FileFrom(it) defer file.Close() return replaceConfig(r, file) diff --git a/core/commands/dag/dag.go b/core/commands/dag/dag.go index 21714630fe2..62f9e1898d4 100644 --- a/core/commands/dag/dag.go +++ b/core/commands/dag/dag.go @@ -14,6 +14,7 @@ import ( cmds "gx/ipfs/QmaAP56JAwdjwisPTu4yx17whcjTr6y5JCSCF77Y1rahWV/go-ipfs-cmds" ipld "gx/ipfs/QmcKKBwfz6FyQdHR2jsXrrF6XeSBXYL86anmWNewpFpoF5/go-ipld-format" cmdkit "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit" + files "gx/ipfs/QmeaQRmnRog7NxLEWHP9zSTkics4cbgwBVa7q49LmBowDr/go-ipfs-files" mh "gx/ipfs/QmerPMzPk1mJVowm8KgmoknWa4yCYvvugMPsgWmDNUvDLW/go-multihash" ) @@ -94,10 +95,10 @@ into an object of the specified format. it := req.Files.Entries() for it.Next() { - if it.File() == nil { + if files.FileFrom(it) == nil { return fmt.Errorf("expected a regular file") } - nds, err := coredag.ParseInputs(ienc, format, it.File(), mhType, -1) + nds, err := coredag.ParseInputs(ienc, format, files.FileFrom(it), mhType, -1) if err != nil { return err } diff --git a/core/commands/files.go b/core/commands/files.go index 20fce2bfc9f..da567067e4f 100644 --- a/core/commands/files.go +++ b/core/commands/files.go @@ -25,6 +25,7 @@ import ( logging "gx/ipfs/QmcuXC5cxs79ro2cUuHs4HQ2bkDLJUYokwL8aivcX6HW3C/go-log" dag "gx/ipfs/QmdV35UHnL1FM52baPkeUo6u7Fxm2CRUkPTLRPxeF8a4Ap/go-merkledag" cmdkit "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit" + files "gx/ipfs/QmeaQRmnRog7NxLEWHP9zSTkics4cbgwBVa7q49LmBowDr/go-ipfs-files" mh "gx/ipfs/QmerPMzPk1mJVowm8KgmoknWa4yCYvvugMPsgWmDNUvDLW/go-multihash" ) @@ -773,11 +774,11 @@ stat' on the file or any of its ancestors. if !it.Next() && it.Err() != nil { return it.Err() } - if it.File() == nil { + if files.FileFrom(it) == nil { return fmt.Errorf("expected a regular file") } - var r io.Reader = it.File() + var r io.Reader = files.FileFrom(it) if countfound { r = io.LimitReader(r, int64(count)) } diff --git a/core/commands/object/object.go b/core/commands/object/object.go index b3ccc3b725a..8b6dfea5992 100644 --- a/core/commands/object/object.go +++ b/core/commands/object/object.go @@ -17,6 +17,7 @@ import ( ipld "gx/ipfs/QmcKKBwfz6FyQdHR2jsXrrF6XeSBXYL86anmWNewpFpoF5/go-ipld-format" dag "gx/ipfs/QmdV35UHnL1FM52baPkeUo6u7Fxm2CRUkPTLRPxeF8a4Ap/go-merkledag" cmdkit "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit" + files "gx/ipfs/QmeaQRmnRog7NxLEWHP9zSTkics4cbgwBVa7q49LmBowDr/go-ipfs-files" ) type Node struct { @@ -395,7 +396,7 @@ And then run: if !it.Next() && it.Err() != nil { return it.Err() } - if it.File() == nil { + if files.FileFrom(it) == nil { return fmt.Errorf("expected a regular file") } @@ -414,7 +415,7 @@ And then run: return err } - p, err := api.Object().Put(req.Context, it.File(), + p, err := api.Object().Put(req.Context, files.FileFrom(it), options.Object.DataType(datafieldenc), options.Object.InputEnc(inputenc), options.Object.Pin(dopin)) diff --git a/core/commands/object/patch.go b/core/commands/object/patch.go index 058fa661a83..52ce58ce2a2 100644 --- a/core/commands/object/patch.go +++ b/core/commands/object/patch.go @@ -10,6 +10,7 @@ import ( "gx/ipfs/QmaAP56JAwdjwisPTu4yx17whcjTr6y5JCSCF77Y1rahWV/go-ipfs-cmds" "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit" + "gx/ipfs/QmeaQRmnRog7NxLEWHP9zSTkics4cbgwBVa7q49LmBowDr/go-ipfs-files" ) var ObjectPatchCmd = &cmds.Command{ @@ -64,11 +65,11 @@ the limit will not be respected by the network. if !it.Next() && it.Err() != nil { return it.Err() } - if it.File() == nil { + if files.FileFrom(it) == nil { return fmt.Errorf("expected a regular file") } - p, err := api.Object().AppendData(req.Context, root, it.File()) + p, err := api.Object().AppendData(req.Context, root, files.FileFrom(it)) if err != nil { return err } @@ -114,11 +115,11 @@ Example: if !it.Next() && it.Err() != nil { return it.Err() } - if it.File() == nil { + if files.FileFrom(it) == nil { return fmt.Errorf("expected a regular file") } - p, err := api.Object().SetData(req.Context, root, it.File()) + p, err := api.Object().SetData(req.Context, root, files.FileFrom(it)) if err != nil { return err } diff --git a/core/commands/tar.go b/core/commands/tar.go index 92939a1eb37..18074063cfd 100644 --- a/core/commands/tar.go +++ b/core/commands/tar.go @@ -13,6 +13,7 @@ import ( cmds "gx/ipfs/QmaAP56JAwdjwisPTu4yx17whcjTr6y5JCSCF77Y1rahWV/go-ipfs-cmds" dag "gx/ipfs/QmdV35UHnL1FM52baPkeUo6u7Fxm2CRUkPTLRPxeF8a4Ap/go-merkledag" cmdkit "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit" + files "gx/ipfs/QmeaQRmnRog7NxLEWHP9zSTkics4cbgwBVa7q49LmBowDr/go-ipfs-files" ) var TarCmd = &cmds.Command{ @@ -48,11 +49,11 @@ represent it. if !it.Next() && it.Err() != nil { return it.Err() } - if it.File() == nil { + if files.FileFrom(it) == nil { return fmt.Errorf("expected a regular file") } - node, err := tar.ImportTar(req.Context, it.File(), nd.DAG) + node, err := tar.ImportTar(req.Context, files.FileFrom(it), nd.DAG) if err != nil { return err } diff --git a/core/coreapi/name_test.go b/core/coreapi/name_test.go index 85049b8b8cf..c97c0832312 100644 --- a/core/coreapi/name_test.go +++ b/core/coreapi/name_test.go @@ -4,7 +4,6 @@ import ( "context" "github.com/ipfs/go-ipfs/core" "io" - "io/ioutil" "math/rand" "path" "testing" @@ -20,7 +19,7 @@ import ( var rnd = rand.New(rand.NewSource(0x62796532303137)) func addTestObject(ctx context.Context, api coreiface.CoreAPI) (coreiface.Path, error) { - return api.Unixfs().Add(ctx, files.NewReaderFile(ioutil.NopCloser(&io.LimitedReader{R: rnd, N: 4092}), nil)) + return api.Unixfs().Add(ctx, files.FileFrom(&io.LimitedReader{R: rnd, N: 4092})) } func appendPath(p coreiface.Path, sub string) coreiface.Path { diff --git a/core/coreapi/unixfile.go b/core/coreapi/unixfile.go index 1ec15ea3734..7aa60febdf5 100644 --- a/core/coreapi/unixfile.go +++ b/core/coreapi/unixfile.go @@ -42,16 +42,6 @@ func (it *ufsIterator) Node() files.Node { return it.curFile } -func (it *ufsIterator) File() files.File { - f, _ := it.curFile.(files.File) - return f -} - -func (it *ufsIterator) Dir() files.Directory { - d, _ := it.curFile.(files.Directory) - return d -} - func (it *ufsIterator) Next() bool { l, ok := <-it.files if !ok { diff --git a/core/coreapi/unixfs_test.go b/core/coreapi/unixfs_test.go index 0ce78665cd8..9c6f02720dd 100644 --- a/core/coreapi/unixfs_test.go +++ b/core/coreapi/unixfs_test.go @@ -136,34 +136,34 @@ func makeAPI(ctx context.Context) (*core.IpfsNode, coreiface.CoreAPI, error) { func strFile(data string) func() files.Node { return func() files.Node { - return files.NewReaderFile(ioutil.NopCloser(strings.NewReader(data)), nil) + return files.FileFrom([]byte(data)) } } func twoLevelDir() func() files.Node { return func() files.Node { - return files.NewSliceFile([]files.DirEntry{ - files.FileEntry("abc", files.NewSliceFile([]files.DirEntry{ - files.FileEntry("def", files.NewReaderFile(ioutil.NopCloser(strings.NewReader("world")), nil)), - })), + return files.DirFrom(map[string]files.Node{ + "abc": files.DirFrom(map[string]files.Node{ + "def": files.FileFrom([]byte("world")), + }), - files.FileEntry("bar", files.NewReaderFile(ioutil.NopCloser(strings.NewReader("hello2")), nil)), - files.FileEntry("foo", files.NewReaderFile(ioutil.NopCloser(strings.NewReader("hello1")), nil)), + "bar": files.FileFrom([]byte("hello2")), + "foo": files.FileFrom([]byte("hello1")), }) } } func flatDir() files.Node { - return files.NewSliceFile([]files.DirEntry{ - files.FileEntry("bar", files.NewReaderFile(ioutil.NopCloser(strings.NewReader("hello2")), nil)), - files.FileEntry("foo", files.NewReaderFile(ioutil.NopCloser(strings.NewReader("hello1")), nil)), + return files.DirFrom(map[string]files.Node{ + "bar": files.FileFrom([]byte("hello2")), + "foo": files.FileFrom([]byte("hello1")), }) } func wrapped(name string) func(f files.Node) files.Node { return func(f files.Node) files.Node { - return files.NewSliceFile([]files.DirEntry{ - files.FileEntry(name, f), + return files.DirFrom(map[string]files.Node{ + name: f, }) } } @@ -296,7 +296,7 @@ func TestAdd(t *testing.T) { name: "addWrapped", path: "/ipfs/QmVE9rNpj5doj7XHzp5zMUxD7BJgXEqx4pe3xZ3JBReWHE", data: func() files.Node { - return files.NewReaderFile(ioutil.NopCloser(strings.NewReader(helloStr)), nil) + return files.FileFrom([]byte(helloStr)) }, wrap: "foo", expect: wrapped("foo"), @@ -306,7 +306,7 @@ func TestAdd(t *testing.T) { name: "addNotWrappedDirFile", path: hello, data: func() files.Node { - return files.NewReaderFile(ioutil.NopCloser(strings.NewReader(helloStr)), nil) + return files.FileFrom([]byte(helloStr)) }, wrap: "foo", }, @@ -314,11 +314,11 @@ func TestAdd(t *testing.T) { name: "stdinWrapped", path: "/ipfs/QmU3r81oZycjHS9oaSHw37ootMFuFUw1DvMLKXPsezdtqU", data: func() files.Node { - return files.NewReaderFile(ioutil.NopCloser(strings.NewReader(helloStr)), nil) + return files.FileFrom([]byte(helloStr)) }, expect: func(files.Node) files.Node { - return files.NewSliceFile([]files.DirEntry{ - files.FileEntry("QmQy2Dw4Wk7rdJKjThjYXzfFJNaRKRHhHP5gHHXroJMYxk", files.NewReaderFile(ioutil.NopCloser(strings.NewReader(helloStr)), nil)), + return files.DirFrom(map[string]files.Node{ + "QmQy2Dw4Wk7rdJKjThjYXzfFJNaRKRHhHP5gHHXroJMYxk": files.FileFrom([]byte(helloStr)), }) }, opts: []options.UnixfsAddOption{options.Unixfs.Wrap(true)}, @@ -335,8 +335,8 @@ func TestAdd(t *testing.T) { return rf }, expect: func(files.Node) files.Node { - return files.NewSliceFile([]files.DirEntry{ - files.FileEntry("test", files.NewReaderFile(ioutil.NopCloser(strings.NewReader(helloStr)), nil)), + return files.DirFrom(map[string]files.Node{ + "test": files.FileFrom([]byte(helloStr)), }) }, opts: []options.UnixfsAddOption{options.Unixfs.Wrap(true), options.Unixfs.StdinName("test")}, @@ -361,10 +361,10 @@ func TestAdd(t *testing.T) { { name: "hiddenFiles", data: func() files.Node { - return files.NewSliceFile([]files.DirEntry{ - files.FileEntry(".bar", files.NewReaderFile(ioutil.NopCloser(strings.NewReader("hello2")), nil)), - files.FileEntry("bar", files.NewReaderFile(ioutil.NopCloser(strings.NewReader("hello2")), nil)), - files.FileEntry("foo", files.NewReaderFile(ioutil.NopCloser(strings.NewReader("hello1")), nil)), + return files.DirFrom(map[string]files.Node{ + ".bar": files.FileFrom([]byte("hello2")), + "bar": files.FileFrom([]byte("hello2")), + "foo": files.FileFrom([]byte("hello1")), }) }, wrap: "t", @@ -374,7 +374,7 @@ func TestAdd(t *testing.T) { { name: "hiddenFileAlwaysAdded", data: func() files.Node { - return files.NewReaderFile(ioutil.NopCloser(strings.NewReader(helloStr)), nil) + return files.FileFrom([]byte(helloStr)) }, wrap: ".foo", path: hello, @@ -382,10 +382,10 @@ func TestAdd(t *testing.T) { { name: "hiddenFilesNotAdded", data: func() files.Node { - return files.NewSliceFile([]files.DirEntry{ - files.FileEntry(".bar", files.NewReaderFile(ioutil.NopCloser(strings.NewReader("hello2")), nil)), - files.FileEntry("bar", files.NewReaderFile(ioutil.NopCloser(strings.NewReader("hello2")), nil)), - files.FileEntry("foo", files.NewReaderFile(ioutil.NopCloser(strings.NewReader("hello1")), nil)), + return files.DirFrom(map[string]files.Node{ + ".bar": files.FileFrom([]byte("hello2")), + "bar": files.FileFrom([]byte("hello2")), + "foo": files.FileFrom([]byte("hello1")), }) }, expect: func(files.Node) files.Node { @@ -432,8 +432,7 @@ func TestAdd(t *testing.T) { { name: "progress1M", data: func() files.Node { - r := bytes.NewReader(bytes.Repeat([]byte{0}, 1000000)) - return files.NewReaderFile(ioutil.NopCloser(r), nil) + return files.FileFrom(bytes.NewReader(bytes.Repeat([]byte{0}, 1000000))) }, path: "/ipfs/QmXXNNbwe4zzpdMg62ZXvnX1oU7MwSrQ3vAEtuwFKCm1oD", events: []coreiface.AddEvent{ diff --git a/core/coreunix/add_test.go b/core/coreunix/add_test.go index fe9e1e0d66f..398ae7bc418 100644 --- a/core/coreunix/add_test.go +++ b/core/coreunix/add_test.go @@ -71,20 +71,18 @@ func TestAddGCLive(t *testing.T) { } adder.Out = out - dataa := ioutil.NopCloser(bytes.NewBufferString("testfileA")) - rfa := files.NewReaderFile(dataa, nil) + rfa := files.FileFrom([]byte("testfileA")) // make two files with pipes so we can 'pause' the add for timing of the test piper, pipew := io.Pipe() - hangfile := files.NewReaderFile(piper, nil) + hangfile := files.FileFrom(piper) - datad := ioutil.NopCloser(bytes.NewBufferString("testfileD")) - rfd := files.NewReaderFile(datad, nil) + rfd := files.FileFrom([]byte("testfileD")) - slf := files.NewSliceFile([]files.DirEntry{ - files.FileEntry("a", rfa), - files.FileEntry("b", hangfile), - files.FileEntry("d", rfd), + slf := files.DirFrom(map[string]files.Node{ + "a": rfa, + "b": hangfile, + "d": rfd, }) addDone := make(chan struct{}) From ff42aa50d0287612c7244a276081586e416a5c3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Thu, 6 Dec 2018 09:29:46 +0100 Subject: [PATCH 11/16] files2.0: Call close in adder MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit License: MIT Signed-off-by: Łukasz Magiera --- core/coreapi/unixfs_test.go | 70 +++++++++++++++++++++++++++++++++++++ core/coreunix/add.go | 1 + 2 files changed, 71 insertions(+) diff --git a/core/coreapi/unixfs_test.go b/core/coreapi/unixfs_test.go index 9c6f02720dd..208c245c12b 100644 --- a/core/coreapi/unixfs_test.go +++ b/core/coreapi/unixfs_test.go @@ -830,3 +830,73 @@ func TestLsNonUnixfs(t *testing.T) { t.Fatalf("expected 0 links, got %d", len(links)) } } + +type closeTestF struct { + files.File + closed bool + + t *testing.T +} + +type closeTestD struct { + files.Directory + closed bool + + t *testing.T +} + +func (f *closeTestD) Close() error { + if f.closed { + f.t.Fatal("already closed") + } + f.closed = true + return nil +} + +func (f *closeTestF) Close() error { + if f.closed { + f.t.Fatal("already closed") + } + f.closed = true + return nil +} + +func TestAddCloses(t *testing.T) { + ctx := context.Background() + _, api, err := makeAPI(ctx) + if err != nil { + t.Error(err) + } + + n4 := &closeTestF{files.FileFrom([]byte("foo")), false, t} + d3 := &closeTestD{files.DirFrom(map[string]files.Node{ + "sub": n4, + }), false, t} + n2 := &closeTestF{files.FileFrom([]byte("bar")), false, t} + n1 := &closeTestF{files.FileFrom([]byte("baz")), false, t} + d0 := &closeTestD{files.DirFrom(map[string]files.Node{ + "a": d3, + "b": n1, + "c": n2, + }), false, t} + + _, err = api.Unixfs().Add(ctx, d0) + if err != nil { + t.Error(err) + } + + d0.Close() // Adder doesn't close top-level file + + for i, n := range []*closeTestF{n1, n2, n4} { + if !n.closed { + t.Errorf("file %d not closed!", i) + } + } + + for i, n := range []*closeTestD{d0, d3} { + if !n.closed { + t.Errorf("dir %d not closed!", i) + } + } + +} diff --git a/core/coreunix/add.go b/core/coreunix/add.go index 2e2641d4e19..020e19bd877 100644 --- a/core/coreunix/add.go +++ b/core/coreunix/add.go @@ -446,6 +446,7 @@ func (adder *Adder) AddAllAndPin(file files.Node) (ipld.Node, error) { } func (adder *Adder) addFile(path string, file files.Node) error { + defer file.Close() err := adder.maybePauseForGC() if err != nil { return err From eed806a58b6eab0c1a703250ae6d607fdfc64bd3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Thu, 13 Dec 2018 22:41:21 +0100 Subject: [PATCH 12/16] files2.0: refactored helpers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit License: MIT Signed-off-by: Łukasz Magiera --- cmd/ipfs/init.go | 6 +-- core/commands/block.go | 6 +-- core/commands/config.go | 6 +-- core/commands/dag/dag.go | 6 +-- core/commands/files.go | 6 +-- core/commands/object/object.go | 6 +-- core/commands/object/patch.go | 10 ++--- core/commands/tar.go | 6 +-- core/coreapi/name_test.go | 2 +- core/coreapi/unixfs_test.go | 68 ++++++++++++++++---------------- core/corehttp/gateway_handler.go | 19 +++++---- core/coreunix/add.go | 20 +++++----- core/coreunix/add_test.go | 8 ++-- 13 files changed, 83 insertions(+), 86 deletions(-) diff --git a/cmd/ipfs/init.go b/cmd/ipfs/init.go index 2ee7488ac3a..b68cb13af95 100644 --- a/cmd/ipfs/init.go +++ b/cmd/ipfs/init.go @@ -16,10 +16,10 @@ import ( namesys "github.com/ipfs/go-ipfs/namesys" fsrepo "github.com/ipfs/go-ipfs/repo/fsrepo" + "gx/ipfs/QmXWZCd8jfaHmt4UDSnjKmGcrQMw95bDGWqEeVLVJjoANX/go-ipfs-files" "gx/ipfs/QmYyzmMnhNTtoXx5ttgUaRdHHckYnQWjPL98hgLAR2QLDD/go-ipfs-config" "gx/ipfs/QmaAP56JAwdjwisPTu4yx17whcjTr6y5JCSCF77Y1rahWV/go-ipfs-cmds" "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit" - "gx/ipfs/QmeaQRmnRog7NxLEWHP9zSTkics4cbgwBVa7q49LmBowDr/go-ipfs-files" ) const ( @@ -90,12 +90,12 @@ environment variable: if !it.Next() && it.Err() != nil { return it.Err() } - if files.FileFrom(it) == nil { + if files.FileFromEntry(it) == nil { return fmt.Errorf("expected a regular file") } conf = &config.Config{} - if err := json.NewDecoder(files.FileFrom(it)).Decode(conf); err != nil { + if err := json.NewDecoder(files.FileFromEntry(it)).Decode(conf); err != nil { return err } } diff --git a/core/commands/block.go b/core/commands/block.go index ec7f6baf42e..b64b80af009 100644 --- a/core/commands/block.go +++ b/core/commands/block.go @@ -11,9 +11,9 @@ import ( coreiface "github.com/ipfs/go-ipfs/core/coreapi/interface" "github.com/ipfs/go-ipfs/core/coreapi/interface/options" + files "gx/ipfs/QmXWZCd8jfaHmt4UDSnjKmGcrQMw95bDGWqEeVLVJjoANX/go-ipfs-files" cmds "gx/ipfs/QmaAP56JAwdjwisPTu4yx17whcjTr6y5JCSCF77Y1rahWV/go-ipfs-cmds" cmdkit "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit" - files "gx/ipfs/QmeaQRmnRog7NxLEWHP9zSTkics4cbgwBVa7q49LmBowDr/go-ipfs-files" mh "gx/ipfs/QmerPMzPk1mJVowm8KgmoknWa4yCYvvugMPsgWmDNUvDLW/go-multihash" ) @@ -158,7 +158,7 @@ than 'sha2-256' or format to anything other than 'v0' will result in CIDv1. if !it.Next() && it.Err() != nil { return it.Err() } - if files.FileFrom(it) == nil { + if files.FileFromEntry(it) == nil { return fmt.Errorf("expected a regular file") } @@ -182,7 +182,7 @@ than 'sha2-256' or format to anything other than 'v0' will result in CIDv1. } } - p, err := api.Block().Put(req.Context, files.FileFrom(it), options.Block.Hash(mhtval, mhlen), options.Block.Format(format)) + p, err := api.Block().Put(req.Context, files.FileFromEntry(it), options.Block.Hash(mhtval, mhlen), options.Block.Format(format)) if err != nil { return err } diff --git a/core/commands/config.go b/core/commands/config.go index ad6f6f30eb8..4eb22a287dd 100644 --- a/core/commands/config.go +++ b/core/commands/config.go @@ -15,10 +15,10 @@ import ( fsrepo "github.com/ipfs/go-ipfs/repo/fsrepo" "gx/ipfs/QmP2i47tnU23ijdshrZtuvrSkQPtf9HhsMb9fwGVe8owj2/jsondiff" + files "gx/ipfs/QmXWZCd8jfaHmt4UDSnjKmGcrQMw95bDGWqEeVLVJjoANX/go-ipfs-files" config "gx/ipfs/QmYyzmMnhNTtoXx5ttgUaRdHHckYnQWjPL98hgLAR2QLDD/go-ipfs-config" cmds "gx/ipfs/QmaAP56JAwdjwisPTu4yx17whcjTr6y5JCSCF77Y1rahWV/go-ipfs-cmds" cmdkit "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit" - files "gx/ipfs/QmeaQRmnRog7NxLEWHP9zSTkics4cbgwBVa7q49LmBowDr/go-ipfs-files" ) // ConfigUpdateOutput is config profile apply command's output @@ -285,10 +285,10 @@ can't be undone. if !it.Next() && it.Err() != nil { return it.Err() } - if files.FileFrom(it) == nil { + if files.FileFromEntry(it) == nil { return fmt.Errorf("expected a regular file") } - file := files.FileFrom(it) + file := files.FileFromEntry(it) defer file.Close() return replaceConfig(r, file) diff --git a/core/commands/dag/dag.go b/core/commands/dag/dag.go index 62f9e1898d4..baf6058b09e 100644 --- a/core/commands/dag/dag.go +++ b/core/commands/dag/dag.go @@ -10,11 +10,11 @@ import ( "github.com/ipfs/go-ipfs/pin" cid "gx/ipfs/QmR8BauakNcBa3RbE4nbQu76PDiJgoQgz8AJdhJuiU4TAw/go-cid" + files "gx/ipfs/QmXWZCd8jfaHmt4UDSnjKmGcrQMw95bDGWqEeVLVJjoANX/go-ipfs-files" path "gx/ipfs/QmZErC2Ay6WuGi96CPg316PwitdwgLo6RxZRqVjJjRj2MR/go-path" cmds "gx/ipfs/QmaAP56JAwdjwisPTu4yx17whcjTr6y5JCSCF77Y1rahWV/go-ipfs-cmds" ipld "gx/ipfs/QmcKKBwfz6FyQdHR2jsXrrF6XeSBXYL86anmWNewpFpoF5/go-ipld-format" cmdkit "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit" - files "gx/ipfs/QmeaQRmnRog7NxLEWHP9zSTkics4cbgwBVa7q49LmBowDr/go-ipfs-files" mh "gx/ipfs/QmerPMzPk1mJVowm8KgmoknWa4yCYvvugMPsgWmDNUvDLW/go-multihash" ) @@ -95,10 +95,10 @@ into an object of the specified format. it := req.Files.Entries() for it.Next() { - if files.FileFrom(it) == nil { + if files.FileFromEntry(it) == nil { return fmt.Errorf("expected a regular file") } - nds, err := coredag.ParseInputs(ienc, format, files.FileFrom(it), mhType, -1) + nds, err := coredag.ParseInputs(ienc, format, files.FileFromEntry(it), mhType, -1) if err != nil { return err } diff --git a/core/commands/files.go b/core/commands/files.go index da567067e4f..0f44c3c64d4 100644 --- a/core/commands/files.go +++ b/core/commands/files.go @@ -18,6 +18,7 @@ import ( bservice "gx/ipfs/QmPoh3SrQzFBWtdGK6qmHDV4EanKR6kYPj4DD3J2NLoEmZ/go-blockservice" cid "gx/ipfs/QmR8BauakNcBa3RbE4nbQu76PDiJgoQgz8AJdhJuiU4TAw/go-cid" mfs "gx/ipfs/QmU3iDRUrxyTYdV2j5MuWLFvP1k7w98vD66PLnNChgvUmZ/go-mfs" + files "gx/ipfs/QmXWZCd8jfaHmt4UDSnjKmGcrQMw95bDGWqEeVLVJjoANX/go-ipfs-files" offline "gx/ipfs/QmYZwey1thDTynSrvd6qQkX24UpTka6TFhQ2v569UpoqxD/go-ipfs-exchange-offline" cmds "gx/ipfs/QmaAP56JAwdjwisPTu4yx17whcjTr6y5JCSCF77Y1rahWV/go-ipfs-cmds" ft "gx/ipfs/Qmbvw7kpSM2p6rbQ57WGRhhqNfCiNGW6EKH4xgHLw4bsnB/go-unixfs" @@ -25,7 +26,6 @@ import ( logging "gx/ipfs/QmcuXC5cxs79ro2cUuHs4HQ2bkDLJUYokwL8aivcX6HW3C/go-log" dag "gx/ipfs/QmdV35UHnL1FM52baPkeUo6u7Fxm2CRUkPTLRPxeF8a4Ap/go-merkledag" cmdkit "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit" - files "gx/ipfs/QmeaQRmnRog7NxLEWHP9zSTkics4cbgwBVa7q49LmBowDr/go-ipfs-files" mh "gx/ipfs/QmerPMzPk1mJVowm8KgmoknWa4yCYvvugMPsgWmDNUvDLW/go-multihash" ) @@ -774,11 +774,11 @@ stat' on the file or any of its ancestors. if !it.Next() && it.Err() != nil { return it.Err() } - if files.FileFrom(it) == nil { + if files.FileFromEntry(it) == nil { return fmt.Errorf("expected a regular file") } - var r io.Reader = files.FileFrom(it) + var r io.Reader = files.FileFromEntry(it) if countfound { r = io.LimitReader(r, int64(count)) } diff --git a/core/commands/object/object.go b/core/commands/object/object.go index 8b6dfea5992..677208232ce 100644 --- a/core/commands/object/object.go +++ b/core/commands/object/object.go @@ -13,11 +13,11 @@ import ( "github.com/ipfs/go-ipfs/core/coreapi/interface/options" cid "gx/ipfs/QmR8BauakNcBa3RbE4nbQu76PDiJgoQgz8AJdhJuiU4TAw/go-cid" + files "gx/ipfs/QmXWZCd8jfaHmt4UDSnjKmGcrQMw95bDGWqEeVLVJjoANX/go-ipfs-files" cmds "gx/ipfs/QmaAP56JAwdjwisPTu4yx17whcjTr6y5JCSCF77Y1rahWV/go-ipfs-cmds" ipld "gx/ipfs/QmcKKBwfz6FyQdHR2jsXrrF6XeSBXYL86anmWNewpFpoF5/go-ipld-format" dag "gx/ipfs/QmdV35UHnL1FM52baPkeUo6u7Fxm2CRUkPTLRPxeF8a4Ap/go-merkledag" cmdkit "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit" - files "gx/ipfs/QmeaQRmnRog7NxLEWHP9zSTkics4cbgwBVa7q49LmBowDr/go-ipfs-files" ) type Node struct { @@ -396,7 +396,7 @@ And then run: if !it.Next() && it.Err() != nil { return it.Err() } - if files.FileFrom(it) == nil { + if files.FileFromEntry(it) == nil { return fmt.Errorf("expected a regular file") } @@ -415,7 +415,7 @@ And then run: return err } - p, err := api.Object().Put(req.Context, files.FileFrom(it), + p, err := api.Object().Put(req.Context, files.FileFromEntry(it), options.Object.DataType(datafieldenc), options.Object.InputEnc(inputenc), options.Object.Pin(dopin)) diff --git a/core/commands/object/patch.go b/core/commands/object/patch.go index 52ce58ce2a2..e39c79b8fb0 100644 --- a/core/commands/object/patch.go +++ b/core/commands/object/patch.go @@ -8,9 +8,9 @@ import ( coreiface "github.com/ipfs/go-ipfs/core/coreapi/interface" "github.com/ipfs/go-ipfs/core/coreapi/interface/options" + "gx/ipfs/QmXWZCd8jfaHmt4UDSnjKmGcrQMw95bDGWqEeVLVJjoANX/go-ipfs-files" "gx/ipfs/QmaAP56JAwdjwisPTu4yx17whcjTr6y5JCSCF77Y1rahWV/go-ipfs-cmds" "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit" - "gx/ipfs/QmeaQRmnRog7NxLEWHP9zSTkics4cbgwBVa7q49LmBowDr/go-ipfs-files" ) var ObjectPatchCmd = &cmds.Command{ @@ -65,11 +65,11 @@ the limit will not be respected by the network. if !it.Next() && it.Err() != nil { return it.Err() } - if files.FileFrom(it) == nil { + if files.FileFromEntry(it) == nil { return fmt.Errorf("expected a regular file") } - p, err := api.Object().AppendData(req.Context, root, files.FileFrom(it)) + p, err := api.Object().AppendData(req.Context, root, files.FileFromEntry(it)) if err != nil { return err } @@ -115,11 +115,11 @@ Example: if !it.Next() && it.Err() != nil { return it.Err() } - if files.FileFrom(it) == nil { + if files.FileFromEntry(it) == nil { return fmt.Errorf("expected a regular file") } - p, err := api.Object().SetData(req.Context, root, files.FileFrom(it)) + p, err := api.Object().SetData(req.Context, root, files.FileFromEntry(it)) if err != nil { return err } diff --git a/core/commands/tar.go b/core/commands/tar.go index 18074063cfd..03626d9d6b2 100644 --- a/core/commands/tar.go +++ b/core/commands/tar.go @@ -9,11 +9,11 @@ import ( coreiface "github.com/ipfs/go-ipfs/core/coreapi/interface" tar "github.com/ipfs/go-ipfs/tar" + files "gx/ipfs/QmXWZCd8jfaHmt4UDSnjKmGcrQMw95bDGWqEeVLVJjoANX/go-ipfs-files" "gx/ipfs/QmZErC2Ay6WuGi96CPg316PwitdwgLo6RxZRqVjJjRj2MR/go-path" cmds "gx/ipfs/QmaAP56JAwdjwisPTu4yx17whcjTr6y5JCSCF77Y1rahWV/go-ipfs-cmds" dag "gx/ipfs/QmdV35UHnL1FM52baPkeUo6u7Fxm2CRUkPTLRPxeF8a4Ap/go-merkledag" cmdkit "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit" - files "gx/ipfs/QmeaQRmnRog7NxLEWHP9zSTkics4cbgwBVa7q49LmBowDr/go-ipfs-files" ) var TarCmd = &cmds.Command{ @@ -49,11 +49,11 @@ represent it. if !it.Next() && it.Err() != nil { return it.Err() } - if files.FileFrom(it) == nil { + if files.FileFromEntry(it) == nil { return fmt.Errorf("expected a regular file") } - node, err := tar.ImportTar(req.Context, files.FileFrom(it), nd.DAG) + node, err := tar.ImportTar(req.Context, files.FileFromEntry(it), nd.DAG) if err != nil { return err } diff --git a/core/coreapi/name_test.go b/core/coreapi/name_test.go index c97c0832312..c93d67f6f38 100644 --- a/core/coreapi/name_test.go +++ b/core/coreapi/name_test.go @@ -19,7 +19,7 @@ import ( var rnd = rand.New(rand.NewSource(0x62796532303137)) func addTestObject(ctx context.Context, api coreiface.CoreAPI) (coreiface.Path, error) { - return api.Unixfs().Add(ctx, files.FileFrom(&io.LimitedReader{R: rnd, N: 4092})) + return api.Unixfs().Add(ctx, files.NewReaderFile(&io.LimitedReader{R: rnd, N: 4092})) } func appendPath(p coreiface.Path, sub string) coreiface.Path { diff --git a/core/coreapi/unixfs_test.go b/core/coreapi/unixfs_test.go index 208c245c12b..c1716cde6db 100644 --- a/core/coreapi/unixfs_test.go +++ b/core/coreapi/unixfs_test.go @@ -136,33 +136,33 @@ func makeAPI(ctx context.Context) (*core.IpfsNode, coreiface.CoreAPI, error) { func strFile(data string) func() files.Node { return func() files.Node { - return files.FileFrom([]byte(data)) + return files.NewBytesFile([]byte(data)) } } func twoLevelDir() func() files.Node { return func() files.Node { - return files.DirFrom(map[string]files.Node{ - "abc": files.DirFrom(map[string]files.Node{ - "def": files.FileFrom([]byte("world")), + return files.NewMapDirectory(map[string]files.Node{ + "abc": files.NewMapDirectory(map[string]files.Node{ + "def": files.NewBytesFile([]byte("world")), }), - "bar": files.FileFrom([]byte("hello2")), - "foo": files.FileFrom([]byte("hello1")), + "bar": files.NewBytesFile([]byte("hello2")), + "foo": files.NewBytesFile([]byte("hello1")), }) } } func flatDir() files.Node { - return files.DirFrom(map[string]files.Node{ - "bar": files.FileFrom([]byte("hello2")), - "foo": files.FileFrom([]byte("hello1")), + return files.NewMapDirectory(map[string]files.Node{ + "bar": files.NewBytesFile([]byte("hello2")), + "foo": files.NewBytesFile([]byte("hello1")), }) } func wrapped(name string) func(f files.Node) files.Node { return func(f files.Node) files.Node { - return files.DirFrom(map[string]files.Node{ + return files.NewMapDirectory(map[string]files.Node{ name: f, }) } @@ -296,7 +296,7 @@ func TestAdd(t *testing.T) { name: "addWrapped", path: "/ipfs/QmVE9rNpj5doj7XHzp5zMUxD7BJgXEqx4pe3xZ3JBReWHE", data: func() files.Node { - return files.FileFrom([]byte(helloStr)) + return files.NewBytesFile([]byte(helloStr)) }, wrap: "foo", expect: wrapped("foo"), @@ -306,7 +306,7 @@ func TestAdd(t *testing.T) { name: "addNotWrappedDirFile", path: hello, data: func() files.Node { - return files.FileFrom([]byte(helloStr)) + return files.NewBytesFile([]byte(helloStr)) }, wrap: "foo", }, @@ -314,11 +314,11 @@ func TestAdd(t *testing.T) { name: "stdinWrapped", path: "/ipfs/QmU3r81oZycjHS9oaSHw37ootMFuFUw1DvMLKXPsezdtqU", data: func() files.Node { - return files.FileFrom([]byte(helloStr)) + return files.NewBytesFile([]byte(helloStr)) }, expect: func(files.Node) files.Node { - return files.DirFrom(map[string]files.Node{ - "QmQy2Dw4Wk7rdJKjThjYXzfFJNaRKRHhHP5gHHXroJMYxk": files.FileFrom([]byte(helloStr)), + return files.NewMapDirectory(map[string]files.Node{ + "QmQy2Dw4Wk7rdJKjThjYXzfFJNaRKRHhHP5gHHXroJMYxk": files.NewBytesFile([]byte(helloStr)), }) }, opts: []options.UnixfsAddOption{options.Unixfs.Wrap(true)}, @@ -335,8 +335,8 @@ func TestAdd(t *testing.T) { return rf }, expect: func(files.Node) files.Node { - return files.DirFrom(map[string]files.Node{ - "test": files.FileFrom([]byte(helloStr)), + return files.NewMapDirectory(map[string]files.Node{ + "test": files.NewBytesFile([]byte(helloStr)), }) }, opts: []options.UnixfsAddOption{options.Unixfs.Wrap(true), options.Unixfs.StdinName("test")}, @@ -361,10 +361,10 @@ func TestAdd(t *testing.T) { { name: "hiddenFiles", data: func() files.Node { - return files.DirFrom(map[string]files.Node{ - ".bar": files.FileFrom([]byte("hello2")), - "bar": files.FileFrom([]byte("hello2")), - "foo": files.FileFrom([]byte("hello1")), + return files.NewMapDirectory(map[string]files.Node{ + ".bar": files.NewBytesFile([]byte("hello2")), + "bar": files.NewBytesFile([]byte("hello2")), + "foo": files.NewBytesFile([]byte("hello1")), }) }, wrap: "t", @@ -374,7 +374,7 @@ func TestAdd(t *testing.T) { { name: "hiddenFileAlwaysAdded", data: func() files.Node { - return files.FileFrom([]byte(helloStr)) + return files.NewBytesFile([]byte(helloStr)) }, wrap: ".foo", path: hello, @@ -382,10 +382,10 @@ func TestAdd(t *testing.T) { { name: "hiddenFilesNotAdded", data: func() files.Node { - return files.DirFrom(map[string]files.Node{ - ".bar": files.FileFrom([]byte("hello2")), - "bar": files.FileFrom([]byte("hello2")), - "foo": files.FileFrom([]byte("hello1")), + return files.NewMapDirectory(map[string]files.Node{ + ".bar": files.NewBytesFile([]byte("hello2")), + "bar": files.NewBytesFile([]byte("hello2")), + "foo": files.NewBytesFile([]byte("hello1")), }) }, expect: func(files.Node) files.Node { @@ -432,7 +432,7 @@ func TestAdd(t *testing.T) { { name: "progress1M", data: func() files.Node { - return files.FileFrom(bytes.NewReader(bytes.Repeat([]byte{0}, 1000000))) + return files.NewReaderFile(bytes.NewReader(bytes.Repeat([]byte{0}, 1000000))) }, path: "/ipfs/QmXXNNbwe4zzpdMg62ZXvnX1oU7MwSrQ3vAEtuwFKCm1oD", events: []coreiface.AddEvent{ @@ -456,8 +456,8 @@ func TestAdd(t *testing.T) { data := testCase.data() if testCase.wrap != "" { - data = files.NewSliceFile([]files.DirEntry{ - files.FileEntry(testCase.wrap, data), + data = files.NewMapDirectory(map[string]files.Node{ + testCase.wrap: data, }) } @@ -868,13 +868,13 @@ func TestAddCloses(t *testing.T) { t.Error(err) } - n4 := &closeTestF{files.FileFrom([]byte("foo")), false, t} - d3 := &closeTestD{files.DirFrom(map[string]files.Node{ + n4 := &closeTestF{files.NewBytesFile([]byte("foo")), false, t} + d3 := &closeTestD{files.NewMapDirectory(map[string]files.Node{ "sub": n4, }), false, t} - n2 := &closeTestF{files.FileFrom([]byte("bar")), false, t} - n1 := &closeTestF{files.FileFrom([]byte("baz")), false, t} - d0 := &closeTestD{files.DirFrom(map[string]files.Node{ + n2 := &closeTestF{files.NewBytesFile([]byte("bar")), false, t} + n1 := &closeTestF{files.NewBytesFile([]byte("baz")), false, t} + d0 := &closeTestD{files.NewMapDirectory(map[string]files.Node{ "a": d3, "b": n1, "c": n2, diff --git a/core/corehttp/gateway_handler.go b/core/corehttp/gateway_handler.go index e0330185e16..553ebdcf8f5 100644 --- a/core/corehttp/gateway_handler.go +++ b/core/corehttp/gateway_handler.go @@ -5,7 +5,6 @@ import ( "errors" "fmt" "io" - "io/ioutil" "net/http" "net/url" "os" @@ -14,23 +13,23 @@ import ( "strings" "time" - core "github.com/ipfs/go-ipfs/core" + "github.com/ipfs/go-ipfs/core" coreiface "github.com/ipfs/go-ipfs/core/coreapi/interface" "github.com/ipfs/go-ipfs/dagutils" - humanize "gx/ipfs/QmPSBJL4momYnE7DcUyk2DVhD6rH488ZmHBGLbxNdhU44K/go-humanize" + "gx/ipfs/QmPSBJL4momYnE7DcUyk2DVhD6rH488ZmHBGLbxNdhU44K/go-humanize" chunker "gx/ipfs/QmR4QQVkBZsZENRjYFVi8dEtPL3daZRNKk24m4r6WKJHNm/go-ipfs-chunker" - cid "gx/ipfs/QmR8BauakNcBa3RbE4nbQu76PDiJgoQgz8AJdhJuiU4TAw/go-cid" - routing "gx/ipfs/QmRASJXJUFygM5qU4YrH7k7jD6S4Hg8nJmgqJ4bYJvLatd/go-libp2p-routing" - files "gx/ipfs/QmXWZCd8jfaHmt4UDSnjKmGcrQMw95bDGWqEeVLVJjoANX/go-ipfs-files" - path "gx/ipfs/QmZErC2Ay6WuGi96CPg316PwitdwgLo6RxZRqVjJjRj2MR/go-path" - resolver "gx/ipfs/QmZErC2Ay6WuGi96CPg316PwitdwgLo6RxZRqVjJjRj2MR/go-path/resolver" + "gx/ipfs/QmR8BauakNcBa3RbE4nbQu76PDiJgoQgz8AJdhJuiU4TAw/go-cid" + "gx/ipfs/QmRASJXJUFygM5qU4YrH7k7jD6S4Hg8nJmgqJ4bYJvLatd/go-libp2p-routing" + "gx/ipfs/QmXWZCd8jfaHmt4UDSnjKmGcrQMw95bDGWqEeVLVJjoANX/go-ipfs-files" + "gx/ipfs/QmZErC2Ay6WuGi96CPg316PwitdwgLo6RxZRqVjJjRj2MR/go-path" + "gx/ipfs/QmZErC2Ay6WuGi96CPg316PwitdwgLo6RxZRqVjJjRj2MR/go-path/resolver" ft "gx/ipfs/Qmbvw7kpSM2p6rbQ57WGRhhqNfCiNGW6EKH4xgHLw4bsnB/go-unixfs" "gx/ipfs/Qmbvw7kpSM2p6rbQ57WGRhhqNfCiNGW6EKH4xgHLw4bsnB/go-unixfs/importer" uio "gx/ipfs/Qmbvw7kpSM2p6rbQ57WGRhhqNfCiNGW6EKH4xgHLw4bsnB/go-unixfs/io" ipld "gx/ipfs/QmcKKBwfz6FyQdHR2jsXrrF6XeSBXYL86anmWNewpFpoF5/go-ipld-format" dag "gx/ipfs/QmdV35UHnL1FM52baPkeUo6u7Fxm2CRUkPTLRPxeF8a4Ap/go-merkledag" - multibase "gx/ipfs/QmekxXDhCxCJRNuzmHreuaT3BsuJcsjcXWNrtV9C8DRHtd/go-multibase" + "gx/ipfs/QmekxXDhCxCJRNuzmHreuaT3BsuJcsjcXWNrtV9C8DRHtd/go-multibase" ) const ( @@ -390,7 +389,7 @@ func (i *gatewayHandler) serveFile(w http.ResponseWriter, req *http.Request, nam } func (i *gatewayHandler) postHandler(ctx context.Context, w http.ResponseWriter, r *http.Request) { - p, err := i.api.Unixfs().Add(ctx, files.NewReaderFile(ioutil.NopCloser(r.Body), nil)) + p, err := i.api.Unixfs().Add(ctx, files.NewReaderFile(r.Body)) if err != nil { internalWebError(w, err) return diff --git a/core/coreunix/add.go b/core/coreunix/add.go index 020e19bd877..2a3b37e0f77 100644 --- a/core/coreunix/add.go +++ b/core/coreunix/add.go @@ -5,26 +5,25 @@ import ( "errors" "fmt" "io" - "io/ioutil" "os" gopath "path" "path/filepath" "strconv" - core "github.com/ipfs/go-ipfs/core" + "github.com/ipfs/go-ipfs/core" coreiface "github.com/ipfs/go-ipfs/core/coreapi/interface" "github.com/ipfs/go-ipfs/pin" chunker "gx/ipfs/QmR4QQVkBZsZENRjYFVi8dEtPL3daZRNKk24m4r6WKJHNm/go-ipfs-chunker" - posinfo "gx/ipfs/QmR6YMs8EkXQLXNwQKxLnQp2VBZSepoEJ8KCZAyanJHhJu/go-ipfs-posinfo" - cid "gx/ipfs/QmR8BauakNcBa3RbE4nbQu76PDiJgoQgz8AJdhJuiU4TAw/go-cid" + "gx/ipfs/QmR6YMs8EkXQLXNwQKxLnQp2VBZSepoEJ8KCZAyanJHhJu/go-ipfs-posinfo" + "gx/ipfs/QmR8BauakNcBa3RbE4nbQu76PDiJgoQgz8AJdhJuiU4TAw/go-cid" bstore "gx/ipfs/QmS2aqUZLJp8kF1ihE5rvDGE5LvmKDPnx32w9Z1BW9xLV5/go-ipfs-blockstore" - mfs "gx/ipfs/QmU3iDRUrxyTYdV2j5MuWLFvP1k7w98vD66PLnNChgvUmZ/go-mfs" - files "gx/ipfs/QmXWZCd8jfaHmt4UDSnjKmGcrQMw95bDGWqEeVLVJjoANX/go-ipfs-files" - unixfs "gx/ipfs/Qmbvw7kpSM2p6rbQ57WGRhhqNfCiNGW6EKH4xgHLw4bsnB/go-unixfs" - balanced "gx/ipfs/Qmbvw7kpSM2p6rbQ57WGRhhqNfCiNGW6EKH4xgHLw4bsnB/go-unixfs/importer/balanced" + "gx/ipfs/QmU3iDRUrxyTYdV2j5MuWLFvP1k7w98vD66PLnNChgvUmZ/go-mfs" + "gx/ipfs/QmXWZCd8jfaHmt4UDSnjKmGcrQMw95bDGWqEeVLVJjoANX/go-ipfs-files" + "gx/ipfs/Qmbvw7kpSM2p6rbQ57WGRhhqNfCiNGW6EKH4xgHLw4bsnB/go-unixfs" + "gx/ipfs/Qmbvw7kpSM2p6rbQ57WGRhhqNfCiNGW6EKH4xgHLw4bsnB/go-unixfs/importer/balanced" ihelper "gx/ipfs/Qmbvw7kpSM2p6rbQ57WGRhhqNfCiNGW6EKH4xgHLw4bsnB/go-unixfs/importer/helpers" - trickle "gx/ipfs/Qmbvw7kpSM2p6rbQ57WGRhhqNfCiNGW6EKH4xgHLw4bsnB/go-unixfs/importer/trickle" + "gx/ipfs/Qmbvw7kpSM2p6rbQ57WGRhhqNfCiNGW6EKH4xgHLw4bsnB/go-unixfs/importer/trickle" ipld "gx/ipfs/QmcKKBwfz6FyQdHR2jsXrrF6XeSBXYL86anmWNewpFpoF5/go-ipld-format" logging "gx/ipfs/QmcuXC5cxs79ro2cUuHs4HQ2bkDLJUYokwL8aivcX6HW3C/go-log" dag "gx/ipfs/QmdV35UHnL1FM52baPkeUo6u7Fxm2CRUkPTLRPxeF8a4Ap/go-merkledag" @@ -341,7 +340,6 @@ func AddR(n *core.IpfsNode, root string) (key string, err error) { // Returns the path of the added file ("/filename"), the DAG node of // the directory, and and error if any. func AddWrapped(n *core.IpfsNode, r io.Reader, filename string) (string, ipld.Node, error) { - file := files.NewReaderFile(ioutil.NopCloser(r), nil) fileAdder, err := NewAdder(n.Context(), n.Pinning, n.Blockstore, n.DAG) if err != nil { return "", nil, err @@ -350,7 +348,7 @@ func AddWrapped(n *core.IpfsNode, r io.Reader, filename string) (string, ipld.No defer n.Blockstore.PinLock().Unlock() - err = fileAdder.addFile(filename, file) + err = fileAdder.addFile(filename, files.NewReaderFile(r)) if err != nil { return "", nil, err } diff --git a/core/coreunix/add_test.go b/core/coreunix/add_test.go index 398ae7bc418..86dca8e6540 100644 --- a/core/coreunix/add_test.go +++ b/core/coreunix/add_test.go @@ -71,15 +71,15 @@ func TestAddGCLive(t *testing.T) { } adder.Out = out - rfa := files.FileFrom([]byte("testfileA")) + rfa := files.NewBytesFile([]byte("testfileA")) // make two files with pipes so we can 'pause' the add for timing of the test piper, pipew := io.Pipe() - hangfile := files.FileFrom(piper) + hangfile := files.NewReaderFile(piper) - rfd := files.FileFrom([]byte("testfileD")) + rfd := files.NewBytesFile([]byte("testfileD")) - slf := files.DirFrom(map[string]files.Node{ + slf := files.NewMapDirectory(map[string]files.Node{ "a": rfa, "b": hangfile, "d": rfd, From 351ed26bd813e9c7dfd02f6b9c3100df4c79ca7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Fri, 14 Dec 2018 12:05:10 +0100 Subject: [PATCH 13/16] files2.0: common single-file helper MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit License: MIT Signed-off-by: Łukasz Magiera --- core/commands/block.go | 12 ++++-------- core/commands/cmdenv/file.go | 22 ++++++++++++++++++++++ core/commands/config.go | 23 +++++++++-------------- core/commands/dag/dag.go | 5 +++-- core/commands/files.go | 31 +++++++++++++------------------ core/commands/object/object.go | 20 ++++++++------------ core/commands/object/patch.go | 23 ++++++++--------------- core/commands/tar.go | 19 ++++++++----------- core/coreunix/add.go | 5 +---- 9 files changed, 76 insertions(+), 84 deletions(-) create mode 100644 core/commands/cmdenv/file.go diff --git a/core/commands/block.go b/core/commands/block.go index b64b80af009..a95f9d93027 100644 --- a/core/commands/block.go +++ b/core/commands/block.go @@ -11,7 +11,6 @@ import ( coreiface "github.com/ipfs/go-ipfs/core/coreapi/interface" "github.com/ipfs/go-ipfs/core/coreapi/interface/options" - files "gx/ipfs/QmXWZCd8jfaHmt4UDSnjKmGcrQMw95bDGWqEeVLVJjoANX/go-ipfs-files" cmds "gx/ipfs/QmaAP56JAwdjwisPTu4yx17whcjTr6y5JCSCF77Y1rahWV/go-ipfs-cmds" cmdkit "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit" mh "gx/ipfs/QmerPMzPk1mJVowm8KgmoknWa4yCYvvugMPsgWmDNUvDLW/go-multihash" @@ -154,12 +153,9 @@ than 'sha2-256' or format to anything other than 'v0' will result in CIDv1. return err } - it := req.Files.Entries() - if !it.Next() && it.Err() != nil { - return it.Err() - } - if files.FileFromEntry(it) == nil { - return fmt.Errorf("expected a regular file") + file, err := cmdenv.GetFileArg(req.Files.Entries()) + if err != nil { + return err } mhtype, _ := req.Options[mhtypeOptionName].(string) @@ -182,7 +178,7 @@ than 'sha2-256' or format to anything other than 'v0' will result in CIDv1. } } - p, err := api.Block().Put(req.Context, files.FileFromEntry(it), options.Block.Hash(mhtval, mhlen), options.Block.Format(format)) + p, err := api.Block().Put(req.Context, file, options.Block.Hash(mhtval, mhlen), options.Block.Format(format)) if err != nil { return err } diff --git a/core/commands/cmdenv/file.go b/core/commands/cmdenv/file.go new file mode 100644 index 00000000000..de162b0d22c --- /dev/null +++ b/core/commands/cmdenv/file.go @@ -0,0 +1,22 @@ +package cmdenv + +import ( + "fmt" + + files "gx/ipfs/QmXWZCd8jfaHmt4UDSnjKmGcrQMw95bDGWqEeVLVJjoANX/go-ipfs-files" +) + +func GetFileArg(it files.DirIterator) (files.File, error) { + if !it.Next() { + err := it.Err() + if err == nil { + err = fmt.Errorf("expected a file argument") + } + return nil, err + } + file := files.FileFromEntry(it) + if file == nil { + return nil, fmt.Errorf("file argument was nil") + } + return file, nil +} diff --git a/core/commands/config.go b/core/commands/config.go index 4eb22a287dd..4227d894f38 100644 --- a/core/commands/config.go +++ b/core/commands/config.go @@ -10,15 +10,14 @@ import ( "os/exec" "strings" - cmdenv "github.com/ipfs/go-ipfs/core/commands/cmdenv" - repo "github.com/ipfs/go-ipfs/repo" - fsrepo "github.com/ipfs/go-ipfs/repo/fsrepo" + "github.com/ipfs/go-ipfs/core/commands/cmdenv" + "github.com/ipfs/go-ipfs/repo" + "github.com/ipfs/go-ipfs/repo/fsrepo" "gx/ipfs/QmP2i47tnU23ijdshrZtuvrSkQPtf9HhsMb9fwGVe8owj2/jsondiff" - files "gx/ipfs/QmXWZCd8jfaHmt4UDSnjKmGcrQMw95bDGWqEeVLVJjoANX/go-ipfs-files" - config "gx/ipfs/QmYyzmMnhNTtoXx5ttgUaRdHHckYnQWjPL98hgLAR2QLDD/go-ipfs-config" - cmds "gx/ipfs/QmaAP56JAwdjwisPTu4yx17whcjTr6y5JCSCF77Y1rahWV/go-ipfs-cmds" - cmdkit "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit" + "gx/ipfs/QmYyzmMnhNTtoXx5ttgUaRdHHckYnQWjPL98hgLAR2QLDD/go-ipfs-config" + "gx/ipfs/QmaAP56JAwdjwisPTu4yx17whcjTr6y5JCSCF77Y1rahWV/go-ipfs-cmds" + "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit" ) // ConfigUpdateOutput is config profile apply command's output @@ -281,14 +280,10 @@ can't be undone. } defer r.Close() - it := req.Files.Entries() - if !it.Next() && it.Err() != nil { - return it.Err() - } - if files.FileFromEntry(it) == nil { - return fmt.Errorf("expected a regular file") + file, err := cmdenv.GetFileArg(req.Files.Entries()) + if err != nil { + return err } - file := files.FileFromEntry(it) defer file.Close() return replaceConfig(r, file) diff --git a/core/commands/dag/dag.go b/core/commands/dag/dag.go index baf6058b09e..beb574dec8d 100644 --- a/core/commands/dag/dag.go +++ b/core/commands/dag/dag.go @@ -95,10 +95,11 @@ into an object of the specified format. it := req.Files.Entries() for it.Next() { - if files.FileFromEntry(it) == nil { + file := files.FileFromEntry(it) + if file == nil { return fmt.Errorf("expected a regular file") } - nds, err := coredag.ParseInputs(ienc, format, files.FileFromEntry(it), mhType, -1) + nds, err := coredag.ParseInputs(ienc, format, file, mhType, -1) if err != nil { return err } diff --git a/core/commands/files.go b/core/commands/files.go index 0f44c3c64d4..2f98fb08353 100644 --- a/core/commands/files.go +++ b/core/commands/files.go @@ -10,22 +10,21 @@ import ( "sort" "strings" - core "github.com/ipfs/go-ipfs/core" - cmdenv "github.com/ipfs/go-ipfs/core/commands/cmdenv" - iface "github.com/ipfs/go-ipfs/core/coreapi/interface" + "github.com/ipfs/go-ipfs/core" + "github.com/ipfs/go-ipfs/core/commands/cmdenv" + "github.com/ipfs/go-ipfs/core/coreapi/interface" - humanize "gx/ipfs/QmPSBJL4momYnE7DcUyk2DVhD6rH488ZmHBGLbxNdhU44K/go-humanize" + "gx/ipfs/QmPSBJL4momYnE7DcUyk2DVhD6rH488ZmHBGLbxNdhU44K/go-humanize" bservice "gx/ipfs/QmPoh3SrQzFBWtdGK6qmHDV4EanKR6kYPj4DD3J2NLoEmZ/go-blockservice" - cid "gx/ipfs/QmR8BauakNcBa3RbE4nbQu76PDiJgoQgz8AJdhJuiU4TAw/go-cid" - mfs "gx/ipfs/QmU3iDRUrxyTYdV2j5MuWLFvP1k7w98vD66PLnNChgvUmZ/go-mfs" - files "gx/ipfs/QmXWZCd8jfaHmt4UDSnjKmGcrQMw95bDGWqEeVLVJjoANX/go-ipfs-files" - offline "gx/ipfs/QmYZwey1thDTynSrvd6qQkX24UpTka6TFhQ2v569UpoqxD/go-ipfs-exchange-offline" - cmds "gx/ipfs/QmaAP56JAwdjwisPTu4yx17whcjTr6y5JCSCF77Y1rahWV/go-ipfs-cmds" + "gx/ipfs/QmR8BauakNcBa3RbE4nbQu76PDiJgoQgz8AJdhJuiU4TAw/go-cid" + "gx/ipfs/QmU3iDRUrxyTYdV2j5MuWLFvP1k7w98vD66PLnNChgvUmZ/go-mfs" + "gx/ipfs/QmYZwey1thDTynSrvd6qQkX24UpTka6TFhQ2v569UpoqxD/go-ipfs-exchange-offline" + "gx/ipfs/QmaAP56JAwdjwisPTu4yx17whcjTr6y5JCSCF77Y1rahWV/go-ipfs-cmds" ft "gx/ipfs/Qmbvw7kpSM2p6rbQ57WGRhhqNfCiNGW6EKH4xgHLw4bsnB/go-unixfs" ipld "gx/ipfs/QmcKKBwfz6FyQdHR2jsXrrF6XeSBXYL86anmWNewpFpoF5/go-ipld-format" logging "gx/ipfs/QmcuXC5cxs79ro2cUuHs4HQ2bkDLJUYokwL8aivcX6HW3C/go-log" dag "gx/ipfs/QmdV35UHnL1FM52baPkeUo6u7Fxm2CRUkPTLRPxeF8a4Ap/go-merkledag" - cmdkit "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit" + "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit" mh "gx/ipfs/QmerPMzPk1mJVowm8KgmoknWa4yCYvvugMPsgWmDNUvDLW/go-multihash" ) @@ -770,15 +769,11 @@ stat' on the file or any of its ancestors. return err } - it := req.Files.Entries() - if !it.Next() && it.Err() != nil { - return it.Err() - } - if files.FileFromEntry(it) == nil { - return fmt.Errorf("expected a regular file") + var r io.Reader + r, err = cmdenv.GetFileArg(req.Files.Entries()) + if err != nil { + return err } - - var r io.Reader = files.FileFromEntry(it) if countfound { r = io.LimitReader(r, int64(count)) } diff --git a/core/commands/object/object.go b/core/commands/object/object.go index 677208232ce..0640a7d6d8c 100644 --- a/core/commands/object/object.go +++ b/core/commands/object/object.go @@ -8,16 +8,15 @@ import ( "io/ioutil" "text/tabwriter" - cmdenv "github.com/ipfs/go-ipfs/core/commands/cmdenv" + "github.com/ipfs/go-ipfs/core/commands/cmdenv" coreiface "github.com/ipfs/go-ipfs/core/coreapi/interface" "github.com/ipfs/go-ipfs/core/coreapi/interface/options" - cid "gx/ipfs/QmR8BauakNcBa3RbE4nbQu76PDiJgoQgz8AJdhJuiU4TAw/go-cid" - files "gx/ipfs/QmXWZCd8jfaHmt4UDSnjKmGcrQMw95bDGWqEeVLVJjoANX/go-ipfs-files" - cmds "gx/ipfs/QmaAP56JAwdjwisPTu4yx17whcjTr6y5JCSCF77Y1rahWV/go-ipfs-cmds" + "gx/ipfs/QmR8BauakNcBa3RbE4nbQu76PDiJgoQgz8AJdhJuiU4TAw/go-cid" + "gx/ipfs/QmaAP56JAwdjwisPTu4yx17whcjTr6y5JCSCF77Y1rahWV/go-ipfs-cmds" ipld "gx/ipfs/QmcKKBwfz6FyQdHR2jsXrrF6XeSBXYL86anmWNewpFpoF5/go-ipld-format" dag "gx/ipfs/QmdV35UHnL1FM52baPkeUo6u7Fxm2CRUkPTLRPxeF8a4Ap/go-merkledag" - cmdkit "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit" + "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit" ) type Node struct { @@ -392,12 +391,9 @@ And then run: return err } - it := req.Files.Entries() - if !it.Next() && it.Err() != nil { - return it.Err() - } - if files.FileFromEntry(it) == nil { - return fmt.Errorf("expected a regular file") + file, err := cmdenv.GetFileArg(req.Files.Entries()) + if err != nil { + return err } inputenc, _ := req.Options["inputenc"].(string) @@ -415,7 +411,7 @@ And then run: return err } - p, err := api.Object().Put(req.Context, files.FileFromEntry(it), + p, err := api.Object().Put(req.Context, file, options.Object.DataType(datafieldenc), options.Object.InputEnc(inputenc), options.Object.Pin(dopin)) diff --git a/core/commands/object/patch.go b/core/commands/object/patch.go index e39c79b8fb0..a7c598898fa 100644 --- a/core/commands/object/patch.go +++ b/core/commands/object/patch.go @@ -8,7 +8,6 @@ import ( coreiface "github.com/ipfs/go-ipfs/core/coreapi/interface" "github.com/ipfs/go-ipfs/core/coreapi/interface/options" - "gx/ipfs/QmXWZCd8jfaHmt4UDSnjKmGcrQMw95bDGWqEeVLVJjoANX/go-ipfs-files" "gx/ipfs/QmaAP56JAwdjwisPTu4yx17whcjTr6y5JCSCF77Y1rahWV/go-ipfs-cmds" "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit" ) @@ -61,15 +60,12 @@ the limit will not be respected by the network. return err } - it := req.Files.Entries() - if !it.Next() && it.Err() != nil { - return it.Err() - } - if files.FileFromEntry(it) == nil { - return fmt.Errorf("expected a regular file") + file, err := cmdenv.GetFileArg(req.Files.Entries()) + if err != nil { + return err } - p, err := api.Object().AppendData(req.Context, root, files.FileFromEntry(it)) + p, err := api.Object().AppendData(req.Context, root, file) if err != nil { return err } @@ -111,15 +107,12 @@ Example: return err } - it := req.Files.Entries() - if !it.Next() && it.Err() != nil { - return it.Err() - } - if files.FileFromEntry(it) == nil { - return fmt.Errorf("expected a regular file") + file, err := cmdenv.GetFileArg(req.Files.Entries()) + if err != nil { + return err } - p, err := api.Object().SetData(req.Context, root, files.FileFromEntry(it)) + p, err := api.Object().SetData(req.Context, root, file) if err != nil { return err } diff --git a/core/commands/tar.go b/core/commands/tar.go index 03626d9d6b2..9604cc3de7f 100644 --- a/core/commands/tar.go +++ b/core/commands/tar.go @@ -4,16 +4,15 @@ import ( "fmt" "io" - core "github.com/ipfs/go-ipfs/core" - cmdenv "github.com/ipfs/go-ipfs/core/commands/cmdenv" + "github.com/ipfs/go-ipfs/core" + "github.com/ipfs/go-ipfs/core/commands/cmdenv" coreiface "github.com/ipfs/go-ipfs/core/coreapi/interface" tar "github.com/ipfs/go-ipfs/tar" - files "gx/ipfs/QmXWZCd8jfaHmt4UDSnjKmGcrQMw95bDGWqEeVLVJjoANX/go-ipfs-files" "gx/ipfs/QmZErC2Ay6WuGi96CPg316PwitdwgLo6RxZRqVjJjRj2MR/go-path" - cmds "gx/ipfs/QmaAP56JAwdjwisPTu4yx17whcjTr6y5JCSCF77Y1rahWV/go-ipfs-cmds" + "gx/ipfs/QmaAP56JAwdjwisPTu4yx17whcjTr6y5JCSCF77Y1rahWV/go-ipfs-cmds" dag "gx/ipfs/QmdV35UHnL1FM52baPkeUo6u7Fxm2CRUkPTLRPxeF8a4Ap/go-merkledag" - cmdkit "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit" + "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit" ) var TarCmd = &cmds.Command{ @@ -46,14 +45,12 @@ represent it. } it := req.Files.Entries() - if !it.Next() && it.Err() != nil { - return it.Err() - } - if files.FileFromEntry(it) == nil { - return fmt.Errorf("expected a regular file") + file, err := cmdenv.GetFileArg(it) + if err != nil { + return err } - node, err := tar.ImportTar(req.Context, files.FileFromEntry(it), nd.DAG) + node, err := tar.ImportTar(req.Context, file, nd.DAG) if err != nil { return err } diff --git a/core/coreunix/add.go b/core/coreunix/add.go index 2a3b37e0f77..b56b8d23db5 100644 --- a/core/coreunix/add.go +++ b/core/coreunix/add.go @@ -547,11 +547,8 @@ func (adder *Adder) addDir(path string, dir files.Directory) error { return err } } - if it.Err() != nil { - return it.Err() - } - return nil + return it.Err() } func (adder *Adder) maybePauseForGC() error { From a92a174526583a305f84f78b0bba0f2485ba1dfa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Fri, 14 Dec 2018 12:37:35 +0100 Subject: [PATCH 14/16] files2.0: return errors from ufsIterator properly MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit License: MIT Signed-off-by: Łukasz Magiera --- core/coreapi/unixfile.go | 35 +++++++++++++++++++++++---- core/coreapi/unixfs_test.go | 47 +++++++++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+), 4 deletions(-) diff --git a/core/coreapi/unixfile.go b/core/coreapi/unixfile.go index 7aa60febdf5..7e4f1782bca 100644 --- a/core/coreapi/unixfile.go +++ b/core/coreapi/unixfile.go @@ -31,7 +31,8 @@ type ufsIterator struct { curName string curFile files.Node - err error + err error + errCh chan error } func (it *ufsIterator) Name() string { @@ -43,11 +44,31 @@ func (it *ufsIterator) Node() files.Node { } func (it *ufsIterator) Next() bool { - l, ok := <-it.files - if !ok { + if it.err != nil { return false } + var l *ipld.Link + var ok bool + for !ok { + if it.files == nil && it.errCh == nil { + return false + } + select { + case l, ok = <-it.files: + if !ok { + it.files = nil + } + case err := <-it.errCh: + it.errCh = nil + it.err = err + + if err != nil { + return false + } + } + } + it.curFile = nil nd, err := l.GetNode(it.ctx, it.dserv) @@ -71,8 +92,12 @@ func (d *ufsDirectory) Close() error { func (d *ufsDirectory) Entries() files.DirIterator { fileCh := make(chan *ipld.Link, prefetchFiles) + errCh := make(chan error, 1) go func() { - d.dir.ForEachLink(d.ctx, func(link *ipld.Link) error { + errCh <- d.dir.ForEachLink(d.ctx, func(link *ipld.Link) error { + if d.ctx.Err() != nil { + return d.ctx.Err() + } select { case fileCh <- link: case <-d.ctx.Done(): @@ -81,12 +106,14 @@ func (d *ufsDirectory) Entries() files.DirIterator { return nil }) + close(errCh) close(fileCh) }() return &ufsIterator{ ctx: d.ctx, files: fileCh, + errCh: errCh, dserv: d.dserv, } } diff --git a/core/coreapi/unixfs_test.go b/core/coreapi/unixfs_test.go index c1716cde6db..f6a1e48d655 100644 --- a/core/coreapi/unixfs_test.go +++ b/core/coreapi/unixfs_test.go @@ -776,6 +776,53 @@ func TestLs(t *testing.T) { } } +func TestEntriesExpired(t *testing.T) { + ctx := context.Background() + node, api, err := makeAPI(ctx) + if err != nil { + t.Error(err) + } + + r := strings.NewReader("content-of-file") + k, _, err := coreunix.AddWrapped(node, r, "name-of-file") + if err != nil { + t.Error(err) + } + parts := strings.Split(k, "/") + if len(parts) != 2 { + t.Errorf("unexpected path: %s", k) + } + p, err := coreiface.ParsePath("/ipfs/" + parts[0]) + if err != nil { + t.Error(err) + } + + ctx, cancel := context.WithCancel(ctx) + + nd, err := api.Unixfs().Get(ctx, p) + if err != nil { + t.Error(err) + } + cancel() + + it := files.ToDir(nd).Entries() + if it == nil { + t.Fatal("it was nil") + } + + if it.Next() { + t.Fatal("Next succeeded") + } + + if it.Err() != context.Canceled { + t.Fatalf("unexpected error %s", it.Err()) + } + + if it.Next() { + t.Fatal("Next succeeded") + } +} + func TestLsEmptyDir(t *testing.T) { ctx := context.Background() node, api, err := makeAPI(ctx) From 1fe28bc658d22de414c142a100fd3c6f27f76ad7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Fri, 14 Dec 2018 12:44:46 +0100 Subject: [PATCH 15/16] files2.0: split adder.addFile into subtyped functions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit License: MIT Signed-off-by: Łukasz Magiera --- core/coreunix/add.go | 58 +++++++++++++++++++++++--------------------- 1 file changed, 31 insertions(+), 27 deletions(-) diff --git a/core/coreunix/add.go b/core/coreunix/add.go index b56b8d23db5..e50adaa084e 100644 --- a/core/coreunix/add.go +++ b/core/coreunix/add.go @@ -322,7 +322,7 @@ func AddR(n *core.IpfsNode, root string) (key string, err error) { return "", err } - err = fileAdder.addFile(filepath.Base(root), f) + err = fileAdder.addFileNode(filepath.Base(root), f) if err != nil { return "", err } @@ -348,7 +348,7 @@ func AddWrapped(n *core.IpfsNode, r io.Reader, filename string) (string, ipld.No defer n.Blockstore.PinLock().Unlock() - err = fileAdder.addFile(filename, files.NewReaderFile(r)) + err = fileAdder.addFileNode(filename, files.NewReaderFile(r)) if err != nil { return "", nil, err } @@ -416,7 +416,7 @@ func (adder *Adder) AddAllAndPin(file files.Node) (ipld.Node, error) { // semantics. it := tf.Entries() for it.Next() { - if err := adder.addFile(it.Name(), it.Node()); err != nil { + if err := adder.addFileNode(it.Name(), it.Node()); err != nil { return nil, err } } @@ -425,7 +425,7 @@ func (adder *Adder) AddAllAndPin(file files.Node) (ipld.Node, error) { } break default: - if err := adder.addFile("", file); err != nil { + if err := adder.addFileNode("", file); err != nil { return nil, err } break @@ -443,7 +443,7 @@ func (adder *Adder) AddAllAndPin(file files.Node) (ipld.Node, error) { return nd, adder.PinRoot() } -func (adder *Adder) addFile(path string, file files.Node) error { +func (adder *Adder) addFileNode(path string, file files.Node) error { defer file.Close() err := adder.maybePauseForGC() if err != nil { @@ -464,34 +464,38 @@ func (adder *Adder) addFile(path string, file files.Node) error { } adder.liveNodes++ - if dir, ok := file.(files.Directory); ok { - return adder.addDir(path, dir) + switch f := file.(type) { + case files.Directory: + return adder.addDir(path, f) + case *files.Symlink: + return adder.addSymlink(path, f) + case files.File: + return adder.addFile(path, f) + default: + return errors.New("unknown file type") } +} - // case for symlink - if s, ok := file.(*files.Symlink); ok { - sdata, err := unixfs.SymlinkData(s.Target) - if err != nil { - return err - } - - dagnode := dag.NodeWithData(sdata) - dagnode.SetCidBuilder(adder.CidBuilder) - err = adder.dagService.Add(adder.ctx, dagnode) - if err != nil { - return err - } +func (adder *Adder) addSymlink(path string, l *files.Symlink) error { + sdata, err := unixfs.SymlinkData(l.Target) + if err != nil { + return err + } - return adder.addNode(dagnode, path) + dagnode := dag.NodeWithData(sdata) + dagnode.SetCidBuilder(adder.CidBuilder) + err = adder.dagService.Add(adder.ctx, dagnode) + if err != nil { + return err } - // case for regular file + return adder.addNode(dagnode, path) +} + +func (adder *Adder) addFile(path string, file files.File) error { // if the progress flag was specified, wrap the file so that we can send // progress updates to the client (over the output channel) - reader, ok := file.(io.Reader) - if !ok { - return errors.New("file doesn't support reading") - } + var reader io.Reader = file if adder.Progress { rdr := &progressReader{file: reader, path: path, out: adder.Out} if fi, ok := file.(files.FileInfo); ok { @@ -542,7 +546,7 @@ func (adder *Adder) addDir(path string, dir files.Directory) error { log.Infof("%s is hidden, skipping", fpath) continue } - err = adder.addFile(fpath, it.Node()) + err = adder.addFileNode(fpath, it.Node()) if err != nil { return err } From a2f15faa4c791b8c803cdaf9bd750b2a632052c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Tue, 18 Dec 2018 02:09:43 +0100 Subject: [PATCH 16/16] files2.0: address review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit License: MIT Signed-off-by: Łukasz Magiera --- cmd/ipfs/init.go | 12 ++++++++---- core/commands/cat.go | 2 +- core/commands/cmdenv/file.go | 1 + core/coreapi/interface/errors.go | 1 + 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/cmd/ipfs/init.go b/cmd/ipfs/init.go index b68cb13af95..8f7796a0ea9 100644 --- a/cmd/ipfs/init.go +++ b/cmd/ipfs/init.go @@ -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 } } diff --git a/core/commands/cat.go b/core/commands/cat.go index 734316927ec..fe25d6dc7d0 100644 --- a/core/commands/cat.go +++ b/core/commands/cat.go @@ -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() diff --git a/core/commands/cmdenv/file.go b/core/commands/cmdenv/file.go index de162b0d22c..c25505dc801 100644 --- a/core/commands/cmdenv/file.go +++ b/core/commands/cmdenv/file.go @@ -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() diff --git a/core/coreapi/interface/errors.go b/core/coreapi/interface/errors.go index 4ee3026ffc7..234abe5667e 100644 --- a/core/coreapi/interface/errors.go +++ b/core/coreapi/interface/errors.go @@ -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") )