mirror of
https://github.com/ipfs/kubo.git
synced 2025-06-25 23:21:54 +08:00
Merge pull request #5306 from ipfs/feat/extract-path
Extract path and resolver
This commit is contained in:
@ -10,7 +10,6 @@ import (
|
||||
"time"
|
||||
|
||||
filestore "github.com/ipfs/go-ipfs/filestore"
|
||||
resolver "github.com/ipfs/go-ipfs/path/resolver"
|
||||
pin "github.com/ipfs/go-ipfs/pin"
|
||||
repo "github.com/ipfs/go-ipfs/repo"
|
||||
cfg "github.com/ipfs/go-ipfs/repo/config"
|
||||
@ -18,6 +17,7 @@ import (
|
||||
uio "github.com/ipfs/go-ipfs/unixfs/io"
|
||||
bserv "gx/ipfs/QmNqRBAhovtf4jVd5cF7YvHaFSsQHHZBaUFwGQWPM2CV7R/go-blockservice"
|
||||
dag "gx/ipfs/QmRy4Qk9hbgFX9NGJRm8rBThrA8PZhNCitMgeRYyZ67s59/go-merkledag"
|
||||
resolver "gx/ipfs/QmYKNMEUK7nCVAefgXF1LVtZEZg3uRmBqiae4FJRXDNAyJ/go-path/resolver"
|
||||
|
||||
offline "gx/ipfs/QmS6mo1dPpHdYsVkm27BRZDLxpKBCiJKUH8fHX15XFfMez/go-ipfs-exchange-offline"
|
||||
goprocessctx "gx/ipfs/QmSF8fPo3jgVBAy8fpdjjYqgG87dkJgUprRBHRd2tmfgpP/goprocess/context"
|
||||
|
@ -10,8 +10,8 @@ import (
|
||||
cmds "github.com/ipfs/go-ipfs/commands"
|
||||
e "github.com/ipfs/go-ipfs/core/commands/e"
|
||||
coredag "github.com/ipfs/go-ipfs/core/coredag"
|
||||
path "github.com/ipfs/go-ipfs/path"
|
||||
pin "github.com/ipfs/go-ipfs/pin"
|
||||
path "gx/ipfs/QmYKNMEUK7nCVAefgXF1LVtZEZg3uRmBqiae4FJRXDNAyJ/go-path"
|
||||
|
||||
mh "gx/ipfs/QmPnFwZ2JXKnXgMw8CdBPxn7FWh6LLdjUjxV1fKHuJnkr8/go-multihash"
|
||||
cid "gx/ipfs/QmYVNvtQkeZ6AKSwDrjQTs432QtL6umrrK41EBq3cu7iSP/go-cid"
|
||||
|
@ -10,8 +10,8 @@ import (
|
||||
|
||||
cmds "github.com/ipfs/go-ipfs/commands"
|
||||
e "github.com/ipfs/go-ipfs/core/commands/e"
|
||||
path "github.com/ipfs/go-ipfs/path"
|
||||
dag "gx/ipfs/QmRy4Qk9hbgFX9NGJRm8rBThrA8PZhNCitMgeRYyZ67s59/go-merkledag"
|
||||
path "gx/ipfs/QmYKNMEUK7nCVAefgXF1LVtZEZg3uRmBqiae4FJRXDNAyJ/go-path"
|
||||
|
||||
b58 "gx/ipfs/QmWFAMPqsEyUX7gDUsRVmMWz59FxSpJ1b2v6bJ1yYzo7jY/go-base58-fast/base58"
|
||||
cid "gx/ipfs/QmYVNvtQkeZ6AKSwDrjQTs432QtL6umrrK41EBq3cu7iSP/go-cid"
|
||||
|
@ -16,12 +16,12 @@ import (
|
||||
core "github.com/ipfs/go-ipfs/core"
|
||||
e "github.com/ipfs/go-ipfs/core/commands/e"
|
||||
mfs "github.com/ipfs/go-ipfs/mfs"
|
||||
path "github.com/ipfs/go-ipfs/path"
|
||||
resolver "github.com/ipfs/go-ipfs/path/resolver"
|
||||
ft "github.com/ipfs/go-ipfs/unixfs"
|
||||
uio "github.com/ipfs/go-ipfs/unixfs/io"
|
||||
bservice "gx/ipfs/QmNqRBAhovtf4jVd5cF7YvHaFSsQHHZBaUFwGQWPM2CV7R/go-blockservice"
|
||||
dag "gx/ipfs/QmRy4Qk9hbgFX9NGJRm8rBThrA8PZhNCitMgeRYyZ67s59/go-merkledag"
|
||||
path "gx/ipfs/QmYKNMEUK7nCVAefgXF1LVtZEZg3uRmBqiae4FJRXDNAyJ/go-path"
|
||||
resolver "gx/ipfs/QmYKNMEUK7nCVAefgXF1LVtZEZg3uRmBqiae4FJRXDNAyJ/go-path/resolver"
|
||||
|
||||
cmds "gx/ipfs/QmNueRyPRQiV7PUEpnP4GgGLuK1rKQLaRW7sfPvUetYig1/go-ipfs-cmds"
|
||||
humanize "gx/ipfs/QmPSBJL4momYnE7DcUyk2DVhD6rH488ZmHBGLbxNdhU44K/go-humanize"
|
||||
|
@ -11,9 +11,9 @@ import (
|
||||
|
||||
core "github.com/ipfs/go-ipfs/core"
|
||||
e "github.com/ipfs/go-ipfs/core/commands/e"
|
||||
path "github.com/ipfs/go-ipfs/path"
|
||||
uarchive "github.com/ipfs/go-ipfs/unixfs/archive"
|
||||
dag "gx/ipfs/QmRy4Qk9hbgFX9NGJRm8rBThrA8PZhNCitMgeRYyZ67s59/go-merkledag"
|
||||
path "gx/ipfs/QmYKNMEUK7nCVAefgXF1LVtZEZg3uRmBqiae4FJRXDNAyJ/go-path"
|
||||
|
||||
"gx/ipfs/QmNueRyPRQiV7PUEpnP4GgGLuK1rKQLaRW7sfPvUetYig1/go-ipfs-cmds"
|
||||
"gx/ipfs/QmPtj12fdwuAqj9sBSTNUxBNu8kCGNp8b3o8yUzMm5GHpq/pb"
|
||||
|
@ -9,13 +9,13 @@ import (
|
||||
cmds "github.com/ipfs/go-ipfs/commands"
|
||||
core "github.com/ipfs/go-ipfs/core"
|
||||
e "github.com/ipfs/go-ipfs/core/commands/e"
|
||||
path "github.com/ipfs/go-ipfs/path"
|
||||
resolver "github.com/ipfs/go-ipfs/path/resolver"
|
||||
unixfs "github.com/ipfs/go-ipfs/unixfs"
|
||||
uio "github.com/ipfs/go-ipfs/unixfs/io"
|
||||
unixfspb "github.com/ipfs/go-ipfs/unixfs/pb"
|
||||
blockservice "gx/ipfs/QmNqRBAhovtf4jVd5cF7YvHaFSsQHHZBaUFwGQWPM2CV7R/go-blockservice"
|
||||
merkledag "gx/ipfs/QmRy4Qk9hbgFX9NGJRm8rBThrA8PZhNCitMgeRYyZ67s59/go-merkledag"
|
||||
path "gx/ipfs/QmYKNMEUK7nCVAefgXF1LVtZEZg3uRmBqiae4FJRXDNAyJ/go-path"
|
||||
resolver "gx/ipfs/QmYKNMEUK7nCVAefgXF1LVtZEZg3uRmBqiae4FJRXDNAyJ/go-path/resolver"
|
||||
|
||||
offline "gx/ipfs/QmS6mo1dPpHdYsVkm27BRZDLxpKBCiJKUH8fHX15XFfMez/go-ipfs-exchange-offline"
|
||||
cid "gx/ipfs/QmYVNvtQkeZ6AKSwDrjQTs432QtL6umrrK41EBq3cu7iSP/go-cid"
|
||||
|
@ -9,7 +9,7 @@ import (
|
||||
core "github.com/ipfs/go-ipfs/core"
|
||||
e "github.com/ipfs/go-ipfs/core/commands/e"
|
||||
"github.com/ipfs/go-ipfs/dagutils"
|
||||
path "github.com/ipfs/go-ipfs/path"
|
||||
path "gx/ipfs/QmYKNMEUK7nCVAefgXF1LVtZEZg3uRmBqiae4FJRXDNAyJ/go-path"
|
||||
cmdkit "gx/ipfs/QmdE4gMduCKCGAcczM2F5ioYDfdeKuPix138wrES1YSr7f/go-ipfs-cmdkit"
|
||||
)
|
||||
|
||||
|
@ -17,10 +17,10 @@ import (
|
||||
lgc "github.com/ipfs/go-ipfs/commands/legacy"
|
||||
core "github.com/ipfs/go-ipfs/core"
|
||||
e "github.com/ipfs/go-ipfs/core/commands/e"
|
||||
path "github.com/ipfs/go-ipfs/path"
|
||||
pin "github.com/ipfs/go-ipfs/pin"
|
||||
ft "github.com/ipfs/go-ipfs/unixfs"
|
||||
dag "gx/ipfs/QmRy4Qk9hbgFX9NGJRm8rBThrA8PZhNCitMgeRYyZ67s59/go-merkledag"
|
||||
path "gx/ipfs/QmYKNMEUK7nCVAefgXF1LVtZEZg3uRmBqiae4FJRXDNAyJ/go-path"
|
||||
|
||||
cmds "gx/ipfs/QmNueRyPRQiV7PUEpnP4GgGLuK1rKQLaRW7sfPvUetYig1/go-ipfs-cmds"
|
||||
cid "gx/ipfs/QmYVNvtQkeZ6AKSwDrjQTs432QtL6umrrK41EBq3cu7iSP/go-cid"
|
||||
|
@ -11,9 +11,9 @@ import (
|
||||
core "github.com/ipfs/go-ipfs/core"
|
||||
e "github.com/ipfs/go-ipfs/core/commands/e"
|
||||
"github.com/ipfs/go-ipfs/dagutils"
|
||||
path "github.com/ipfs/go-ipfs/path"
|
||||
ft "github.com/ipfs/go-ipfs/unixfs"
|
||||
dag "gx/ipfs/QmRy4Qk9hbgFX9NGJRm8rBThrA8PZhNCitMgeRYyZ67s59/go-merkledag"
|
||||
path "gx/ipfs/QmYKNMEUK7nCVAefgXF1LVtZEZg3uRmBqiae4FJRXDNAyJ/go-path"
|
||||
|
||||
cmds "gx/ipfs/QmNueRyPRQiV7PUEpnP4GgGLuK1rKQLaRW7sfPvUetYig1/go-ipfs-cmds"
|
||||
logging "gx/ipfs/QmcVVHfdyv15GVPk7NrxdWjh2hLVccXnoD8j2tyQShiXJb/go-log"
|
||||
|
@ -11,12 +11,12 @@ import (
|
||||
core "github.com/ipfs/go-ipfs/core"
|
||||
e "github.com/ipfs/go-ipfs/core/commands/e"
|
||||
corerepo "github.com/ipfs/go-ipfs/core/corerepo"
|
||||
path "github.com/ipfs/go-ipfs/path"
|
||||
resolver "github.com/ipfs/go-ipfs/path/resolver"
|
||||
pin "github.com/ipfs/go-ipfs/pin"
|
||||
uio "github.com/ipfs/go-ipfs/unixfs/io"
|
||||
bserv "gx/ipfs/QmNqRBAhovtf4jVd5cF7YvHaFSsQHHZBaUFwGQWPM2CV7R/go-blockservice"
|
||||
dag "gx/ipfs/QmRy4Qk9hbgFX9NGJRm8rBThrA8PZhNCitMgeRYyZ67s59/go-merkledag"
|
||||
path "gx/ipfs/QmYKNMEUK7nCVAefgXF1LVtZEZg3uRmBqiae4FJRXDNAyJ/go-path"
|
||||
resolver "gx/ipfs/QmYKNMEUK7nCVAefgXF1LVtZEZg3uRmBqiae4FJRXDNAyJ/go-path/resolver"
|
||||
|
||||
u "gx/ipfs/QmPdKqUcHGFdeSpvjVoaTRPPstGif9GBZb5Q56RVw9o69A/go-ipfs-util"
|
||||
"gx/ipfs/QmQwgv79RHrRnoXmhnpC1BPtY55HHeneGMpPwmmBU1fUAG/go-verifcid"
|
||||
|
@ -12,7 +12,7 @@ import (
|
||||
core "github.com/ipfs/go-ipfs/core"
|
||||
e "github.com/ipfs/go-ipfs/core/commands/e"
|
||||
keystore "github.com/ipfs/go-ipfs/keystore"
|
||||
path "github.com/ipfs/go-ipfs/path"
|
||||
path "gx/ipfs/QmYKNMEUK7nCVAefgXF1LVtZEZg3uRmBqiae4FJRXDNAyJ/go-path"
|
||||
|
||||
"gx/ipfs/QmdE4gMduCKCGAcczM2F5ioYDfdeKuPix138wrES1YSr7f/go-ipfs-cmdkit"
|
||||
peer "gx/ipfs/QmdVrMn1LhB4ybb8hMVaMLXnA8XRSewMnK6YqXKXoTcRvN/go-libp2p-peer"
|
||||
|
@ -10,7 +10,7 @@ import (
|
||||
cmds "github.com/ipfs/go-ipfs/commands"
|
||||
"github.com/ipfs/go-ipfs/core"
|
||||
e "github.com/ipfs/go-ipfs/core/commands/e"
|
||||
path "github.com/ipfs/go-ipfs/path"
|
||||
path "gx/ipfs/QmYKNMEUK7nCVAefgXF1LVtZEZg3uRmBqiae4FJRXDNAyJ/go-path"
|
||||
|
||||
cid "gx/ipfs/QmYVNvtQkeZ6AKSwDrjQTs432QtL6umrrK41EBq3cu7iSP/go-cid"
|
||||
ipld "gx/ipfs/QmZtNq8dArGfnpCZfx2pUNY7UcjGhVp5qqwQ4hH6mpTMRQ/go-ipld-format"
|
||||
|
@ -11,7 +11,7 @@ import (
|
||||
e "github.com/ipfs/go-ipfs/core/commands/e"
|
||||
ns "github.com/ipfs/go-ipfs/namesys"
|
||||
nsopts "github.com/ipfs/go-ipfs/namesys/opts"
|
||||
path "github.com/ipfs/go-ipfs/path"
|
||||
path "gx/ipfs/QmYKNMEUK7nCVAefgXF1LVtZEZg3uRmBqiae4FJRXDNAyJ/go-path"
|
||||
|
||||
"gx/ipfs/QmdE4gMduCKCGAcczM2F5ioYDfdeKuPix138wrES1YSr7f/go-ipfs-cmdkit"
|
||||
)
|
||||
|
@ -8,9 +8,9 @@ import (
|
||||
core "github.com/ipfs/go-ipfs/core"
|
||||
e "github.com/ipfs/go-ipfs/core/commands/e"
|
||||
"github.com/ipfs/go-ipfs/core/coreunix"
|
||||
path "github.com/ipfs/go-ipfs/path"
|
||||
tar "github.com/ipfs/go-ipfs/tar"
|
||||
dag "gx/ipfs/QmRy4Qk9hbgFX9NGJRm8rBThrA8PZhNCitMgeRYyZ67s59/go-merkledag"
|
||||
path "gx/ipfs/QmYKNMEUK7nCVAefgXF1LVtZEZg3uRmBqiae4FJRXDNAyJ/go-path"
|
||||
|
||||
"gx/ipfs/QmdE4gMduCKCGAcczM2F5ioYDfdeKuPix138wrES1YSr7f/go-ipfs-cmdkit"
|
||||
)
|
||||
|
@ -12,12 +12,12 @@ import (
|
||||
cmds "github.com/ipfs/go-ipfs/commands"
|
||||
core "github.com/ipfs/go-ipfs/core"
|
||||
e "github.com/ipfs/go-ipfs/core/commands/e"
|
||||
path "github.com/ipfs/go-ipfs/path"
|
||||
resolver "github.com/ipfs/go-ipfs/path/resolver"
|
||||
unixfs "github.com/ipfs/go-ipfs/unixfs"
|
||||
uio "github.com/ipfs/go-ipfs/unixfs/io"
|
||||
unixfspb "github.com/ipfs/go-ipfs/unixfs/pb"
|
||||
merkledag "gx/ipfs/QmRy4Qk9hbgFX9NGJRm8rBThrA8PZhNCitMgeRYyZ67s59/go-merkledag"
|
||||
path "gx/ipfs/QmYKNMEUK7nCVAefgXF1LVtZEZg3uRmBqiae4FJRXDNAyJ/go-path"
|
||||
resolver "gx/ipfs/QmYKNMEUK7nCVAefgXF1LVtZEZg3uRmBqiae4FJRXDNAyJ/go-path/resolver"
|
||||
)
|
||||
|
||||
type LsLink struct {
|
||||
|
@ -27,7 +27,6 @@ import (
|
||||
namesys "github.com/ipfs/go-ipfs/namesys"
|
||||
ipnsrp "github.com/ipfs/go-ipfs/namesys/republisher"
|
||||
p2p "github.com/ipfs/go-ipfs/p2p"
|
||||
"github.com/ipfs/go-ipfs/path/resolver"
|
||||
pin "github.com/ipfs/go-ipfs/pin"
|
||||
repo "github.com/ipfs/go-ipfs/repo"
|
||||
config "github.com/ipfs/go-ipfs/repo/config"
|
||||
@ -36,6 +35,7 @@ import (
|
||||
merkledag "gx/ipfs/QmRy4Qk9hbgFX9NGJRm8rBThrA8PZhNCitMgeRYyZ67s59/go-merkledag"
|
||||
bitswap "gx/ipfs/QmSLYFS88MpPsszqWdhGSxvHyoTnmaU4A74SD6KGib6Z3m/go-bitswap"
|
||||
bsnet "gx/ipfs/QmSLYFS88MpPsszqWdhGSxvHyoTnmaU4A74SD6KGib6Z3m/go-bitswap/network"
|
||||
"gx/ipfs/QmYKNMEUK7nCVAefgXF1LVtZEZg3uRmBqiae4FJRXDNAyJ/go-path/resolver"
|
||||
|
||||
u "gx/ipfs/QmPdKqUcHGFdeSpvjVoaTRPPstGif9GBZb5Q56RVw9o69A/go-ipfs-util"
|
||||
rhelpers "gx/ipfs/QmQpvpeXa8rBfDmt3bdh2ckw2867vsYN1ozf79X7U5rij9/go-libp2p-routing-helpers"
|
||||
|
@ -1,7 +1,7 @@
|
||||
package iface
|
||||
|
||||
import (
|
||||
ipfspath "github.com/ipfs/go-ipfs/path"
|
||||
ipfspath "gx/ipfs/QmYKNMEUK7nCVAefgXF1LVtZEZg3uRmBqiae4FJRXDNAyJ/go-path"
|
||||
|
||||
cid "gx/ipfs/QmYVNvtQkeZ6AKSwDrjQTs432QtL6umrrK41EBq3cu7iSP/go-cid"
|
||||
)
|
||||
|
@ -8,7 +8,7 @@ import (
|
||||
|
||||
coreiface "github.com/ipfs/go-ipfs/core/coreapi/interface"
|
||||
caopts "github.com/ipfs/go-ipfs/core/coreapi/interface/options"
|
||||
ipfspath "github.com/ipfs/go-ipfs/path"
|
||||
ipfspath "gx/ipfs/QmYKNMEUK7nCVAefgXF1LVtZEZg3uRmBqiae4FJRXDNAyJ/go-path"
|
||||
|
||||
peer "gx/ipfs/QmdVrMn1LhB4ybb8hMVaMLXnA8XRSewMnK6YqXKXoTcRvN/go-libp2p-peer"
|
||||
crypto "gx/ipfs/Qme1knMqwt1hKZbc1BmQFmnm9f36nyQGwXxPGVpVJ9rMK5/go-libp2p-crypto"
|
||||
|
@ -13,7 +13,7 @@ import (
|
||||
keystore "github.com/ipfs/go-ipfs/keystore"
|
||||
namesys "github.com/ipfs/go-ipfs/namesys"
|
||||
nsopts "github.com/ipfs/go-ipfs/namesys/opts"
|
||||
ipath "github.com/ipfs/go-ipfs/path"
|
||||
ipath "gx/ipfs/QmYKNMEUK7nCVAefgXF1LVtZEZg3uRmBqiae4FJRXDNAyJ/go-path"
|
||||
|
||||
offline "gx/ipfs/QmbFRJeEmEU16y3BmKKaD4a9fm5oHsEAMHe2vSB1UnfLMi/go-ipfs-routing/offline"
|
||||
peer "gx/ipfs/QmdVrMn1LhB4ybb8hMVaMLXnA8XRSewMnK6YqXKXoTcRvN/go-libp2p-peer"
|
||||
|
@ -7,7 +7,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
ipath "github.com/ipfs/go-ipfs/path"
|
||||
ipath "gx/ipfs/QmYKNMEUK7nCVAefgXF1LVtZEZg3uRmBqiae4FJRXDNAyJ/go-path"
|
||||
|
||||
coreiface "github.com/ipfs/go-ipfs/core/coreapi/interface"
|
||||
opt "github.com/ipfs/go-ipfs/core/coreapi/interface/options"
|
||||
|
@ -8,9 +8,9 @@ import (
|
||||
core "github.com/ipfs/go-ipfs/core"
|
||||
coreiface "github.com/ipfs/go-ipfs/core/coreapi/interface"
|
||||
namesys "github.com/ipfs/go-ipfs/namesys"
|
||||
ipfspath "github.com/ipfs/go-ipfs/path"
|
||||
resolver "github.com/ipfs/go-ipfs/path/resolver"
|
||||
uio "github.com/ipfs/go-ipfs/unixfs/io"
|
||||
ipfspath "gx/ipfs/QmYKNMEUK7nCVAefgXF1LVtZEZg3uRmBqiae4FJRXDNAyJ/go-path"
|
||||
resolver "gx/ipfs/QmYKNMEUK7nCVAefgXF1LVtZEZg3uRmBqiae4FJRXDNAyJ/go-path/resolver"
|
||||
|
||||
cid "gx/ipfs/QmYVNvtQkeZ6AKSwDrjQTs432QtL6umrrK41EBq3cu7iSP/go-cid"
|
||||
ipld "gx/ipfs/QmZtNq8dArGfnpCZfx2pUNY7UcjGhVp5qqwQ4hH6mpTMRQ/go-ipld-format"
|
||||
|
@ -12,8 +12,8 @@ import (
|
||||
oldcmds "github.com/ipfs/go-ipfs/commands"
|
||||
core "github.com/ipfs/go-ipfs/core"
|
||||
corecommands "github.com/ipfs/go-ipfs/core/commands"
|
||||
path "github.com/ipfs/go-ipfs/path"
|
||||
config "github.com/ipfs/go-ipfs/repo/config"
|
||||
path "gx/ipfs/QmYKNMEUK7nCVAefgXF1LVtZEZg3uRmBqiae4FJRXDNAyJ/go-path"
|
||||
|
||||
cmds "gx/ipfs/QmNueRyPRQiV7PUEpnP4GgGLuK1rKQLaRW7sfPvUetYig1/go-ipfs-cmds"
|
||||
cmdsHttp "gx/ipfs/QmNueRyPRQiV7PUEpnP4GgGLuK1rKQLaRW7sfPvUetYig1/go-ipfs-cmds/http"
|
||||
|
@ -16,11 +16,11 @@ import (
|
||||
coreiface "github.com/ipfs/go-ipfs/core/coreapi/interface"
|
||||
"github.com/ipfs/go-ipfs/dagutils"
|
||||
"github.com/ipfs/go-ipfs/importer"
|
||||
path "github.com/ipfs/go-ipfs/path"
|
||||
resolver "github.com/ipfs/go-ipfs/path/resolver"
|
||||
ft "github.com/ipfs/go-ipfs/unixfs"
|
||||
uio "github.com/ipfs/go-ipfs/unixfs/io"
|
||||
dag "gx/ipfs/QmRy4Qk9hbgFX9NGJRm8rBThrA8PZhNCitMgeRYyZ67s59/go-merkledag"
|
||||
path "gx/ipfs/QmYKNMEUK7nCVAefgXF1LVtZEZg3uRmBqiae4FJRXDNAyJ/go-path"
|
||||
resolver "gx/ipfs/QmYKNMEUK7nCVAefgXF1LVtZEZg3uRmBqiae4FJRXDNAyJ/go-path/resolver"
|
||||
|
||||
humanize "gx/ipfs/QmPSBJL4momYnE7DcUyk2DVhD6rH488ZmHBGLbxNdhU44K/go-humanize"
|
||||
chunker "gx/ipfs/QmVDjhUMtkRskBFAVNwyXuLSKbeAya7JKPnzAxMKDaK4x4/go-ipfs-chunker"
|
||||
|
@ -15,10 +15,10 @@ import (
|
||||
coreunix "github.com/ipfs/go-ipfs/core/coreunix"
|
||||
namesys "github.com/ipfs/go-ipfs/namesys"
|
||||
nsopts "github.com/ipfs/go-ipfs/namesys/opts"
|
||||
path "github.com/ipfs/go-ipfs/path"
|
||||
repo "github.com/ipfs/go-ipfs/repo"
|
||||
config "github.com/ipfs/go-ipfs/repo/config"
|
||||
dag "gx/ipfs/QmRy4Qk9hbgFX9NGJRm8rBThrA8PZhNCitMgeRYyZ67s59/go-merkledag"
|
||||
path "gx/ipfs/QmYKNMEUK7nCVAefgXF1LVtZEZg3uRmBqiae4FJRXDNAyJ/go-path"
|
||||
|
||||
id "gx/ipfs/QmY51bqSM5XgxQZqsBrQcRkKTnCb8EKpJpR9K6Qax7Njco/go-libp2p/p2p/protocol/identify"
|
||||
ci "gx/ipfs/Qme1knMqwt1hKZbc1BmQFmnm9f36nyQGwXxPGVpVJ9rMK5/go-libp2p-crypto"
|
||||
|
@ -18,9 +18,9 @@ import (
|
||||
"fmt"
|
||||
|
||||
"github.com/ipfs/go-ipfs/core"
|
||||
path "github.com/ipfs/go-ipfs/path"
|
||||
resolver "github.com/ipfs/go-ipfs/path/resolver"
|
||||
uio "github.com/ipfs/go-ipfs/unixfs/io"
|
||||
path "gx/ipfs/QmYKNMEUK7nCVAefgXF1LVtZEZg3uRmBqiae4FJRXDNAyJ/go-path"
|
||||
resolver "gx/ipfs/QmYKNMEUK7nCVAefgXF1LVtZEZg3uRmBqiae4FJRXDNAyJ/go-path/resolver"
|
||||
|
||||
cid "gx/ipfs/QmYVNvtQkeZ6AKSwDrjQTs432QtL6umrrK41EBq3cu7iSP/go-cid"
|
||||
)
|
||||
|
@ -4,9 +4,9 @@ import (
|
||||
"context"
|
||||
|
||||
core "github.com/ipfs/go-ipfs/core"
|
||||
path "github.com/ipfs/go-ipfs/path"
|
||||
resolver "github.com/ipfs/go-ipfs/path/resolver"
|
||||
uio "github.com/ipfs/go-ipfs/unixfs/io"
|
||||
path "gx/ipfs/QmYKNMEUK7nCVAefgXF1LVtZEZg3uRmBqiae4FJRXDNAyJ/go-path"
|
||||
resolver "gx/ipfs/QmYKNMEUK7nCVAefgXF1LVtZEZg3uRmBqiae4FJRXDNAyJ/go-path/resolver"
|
||||
)
|
||||
|
||||
func Cat(ctx context.Context, n *core.IpfsNode, pstr string) (uio.DagReader, error) {
|
||||
|
@ -6,8 +6,8 @@ import (
|
||||
"strings"
|
||||
|
||||
namesys "github.com/ipfs/go-ipfs/namesys"
|
||||
path "github.com/ipfs/go-ipfs/path"
|
||||
resolver "github.com/ipfs/go-ipfs/path/resolver"
|
||||
path "gx/ipfs/QmYKNMEUK7nCVAefgXF1LVtZEZg3uRmBqiae4FJRXDNAyJ/go-path"
|
||||
resolver "gx/ipfs/QmYKNMEUK7nCVAefgXF1LVtZEZg3uRmBqiae4FJRXDNAyJ/go-path/resolver"
|
||||
|
||||
cid "gx/ipfs/QmYVNvtQkeZ6AKSwDrjQTs432QtL6umrrK41EBq3cu7iSP/go-cid"
|
||||
ipld "gx/ipfs/QmZtNq8dArGfnpCZfx2pUNY7UcjGhVp5qqwQ4hH6mpTMRQ/go-ipld-format"
|
||||
|
@ -5,7 +5,7 @@ import (
|
||||
|
||||
core "github.com/ipfs/go-ipfs/core"
|
||||
coremock "github.com/ipfs/go-ipfs/core/mock"
|
||||
path "github.com/ipfs/go-ipfs/path"
|
||||
path "gx/ipfs/QmYKNMEUK7nCVAefgXF1LVtZEZg3uRmBqiae4FJRXDNAyJ/go-path"
|
||||
)
|
||||
|
||||
func TestResolveNoComponents(t *testing.T) {
|
||||
|
@ -4,9 +4,9 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
|
||||
path "github.com/ipfs/go-ipfs/path"
|
||||
bserv "gx/ipfs/QmNqRBAhovtf4jVd5cF7YvHaFSsQHHZBaUFwGQWPM2CV7R/go-blockservice"
|
||||
dag "gx/ipfs/QmRy4Qk9hbgFX9NGJRm8rBThrA8PZhNCitMgeRYyZ67s59/go-merkledag"
|
||||
path "gx/ipfs/QmYKNMEUK7nCVAefgXF1LVtZEZg3uRmBqiae4FJRXDNAyJ/go-path"
|
||||
|
||||
offline "gx/ipfs/QmS6mo1dPpHdYsVkm27BRZDLxpKBCiJKUH8fHX15XFfMez/go-ipfs-exchange-offline"
|
||||
ipld "gx/ipfs/QmZtNq8dArGfnpCZfx2pUNY7UcjGhVp5qqwQ4hH6mpTMRQ/go-ipld-format"
|
||||
|
@ -4,9 +4,9 @@ import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
path "github.com/ipfs/go-ipfs/path"
|
||||
dag "gx/ipfs/QmRy4Qk9hbgFX9NGJRm8rBThrA8PZhNCitMgeRYyZ67s59/go-merkledag"
|
||||
mdtest "gx/ipfs/QmRy4Qk9hbgFX9NGJRm8rBThrA8PZhNCitMgeRYyZ67s59/go-merkledag/test"
|
||||
path "gx/ipfs/QmYKNMEUK7nCVAefgXF1LVtZEZg3uRmBqiae4FJRXDNAyJ/go-path"
|
||||
|
||||
cid "gx/ipfs/QmYVNvtQkeZ6AKSwDrjQTs432QtL6umrrK41EBq3cu7iSP/go-cid"
|
||||
ipld "gx/ipfs/QmZtNq8dArGfnpCZfx2pUNY7UcjGhVp5qqwQ4hH6mpTMRQ/go-ipld-format"
|
||||
|
@ -5,8 +5,8 @@ import (
|
||||
|
||||
"github.com/ipfs/go-ipfs/core"
|
||||
nsys "github.com/ipfs/go-ipfs/namesys"
|
||||
path "github.com/ipfs/go-ipfs/path"
|
||||
ft "github.com/ipfs/go-ipfs/unixfs"
|
||||
path "gx/ipfs/QmYKNMEUK7nCVAefgXF1LVtZEZg3uRmBqiae4FJRXDNAyJ/go-path"
|
||||
ci "gx/ipfs/Qme1knMqwt1hKZbc1BmQFmnm9f36nyQGwXxPGVpVJ9rMK5/go-libp2p-crypto"
|
||||
)
|
||||
|
||||
|
@ -14,9 +14,9 @@ import (
|
||||
core "github.com/ipfs/go-ipfs/core"
|
||||
mfs "github.com/ipfs/go-ipfs/mfs"
|
||||
namesys "github.com/ipfs/go-ipfs/namesys"
|
||||
path "github.com/ipfs/go-ipfs/path"
|
||||
ft "github.com/ipfs/go-ipfs/unixfs"
|
||||
dag "gx/ipfs/QmRy4Qk9hbgFX9NGJRm8rBThrA8PZhNCitMgeRYyZ67s59/go-merkledag"
|
||||
path "gx/ipfs/QmYKNMEUK7nCVAefgXF1LVtZEZg3uRmBqiae4FJRXDNAyJ/go-path"
|
||||
|
||||
fuse "gx/ipfs/QmSJBsmLP1XMjv8hxYg2rUMdPDB7YUpyBo9idjrJ6Cmq6F/fuse"
|
||||
fs "gx/ipfs/QmSJBsmLP1XMjv8hxYg2rUMdPDB7YUpyBo9idjrJ6Cmq6F/fuse/fs"
|
||||
|
@ -11,10 +11,10 @@ import (
|
||||
"syscall"
|
||||
|
||||
core "github.com/ipfs/go-ipfs/core"
|
||||
path "github.com/ipfs/go-ipfs/path"
|
||||
uio "github.com/ipfs/go-ipfs/unixfs/io"
|
||||
ftpb "github.com/ipfs/go-ipfs/unixfs/pb"
|
||||
mdag "gx/ipfs/QmRy4Qk9hbgFX9NGJRm8rBThrA8PZhNCitMgeRYyZ67s59/go-merkledag"
|
||||
path "gx/ipfs/QmYKNMEUK7nCVAefgXF1LVtZEZg3uRmBqiae4FJRXDNAyJ/go-path"
|
||||
|
||||
lgbl "gx/ipfs/QmRPkGkHLB72caXgdDYnoaWigXNWx95BcYDKV1n3KTEpaG/go-libp2p-loggables"
|
||||
fuse "gx/ipfs/QmSJBsmLP1XMjv8hxYg2rUMdPDB7YUpyBo9idjrJ6Cmq6F/fuse"
|
||||
|
@ -15,11 +15,11 @@ import (
|
||||
"time"
|
||||
|
||||
importer "github.com/ipfs/go-ipfs/importer"
|
||||
"github.com/ipfs/go-ipfs/path"
|
||||
ft "github.com/ipfs/go-ipfs/unixfs"
|
||||
uio "github.com/ipfs/go-ipfs/unixfs/io"
|
||||
bserv "gx/ipfs/QmNqRBAhovtf4jVd5cF7YvHaFSsQHHZBaUFwGQWPM2CV7R/go-blockservice"
|
||||
dag "gx/ipfs/QmRy4Qk9hbgFX9NGJRm8rBThrA8PZhNCitMgeRYyZ67s59/go-merkledag"
|
||||
"gx/ipfs/QmYKNMEUK7nCVAefgXF1LVtZEZg3uRmBqiae4FJRXDNAyJ/go-path"
|
||||
|
||||
u "gx/ipfs/QmPdKqUcHGFdeSpvjVoaTRPPstGif9GBZb5Q56RVw9o69A/go-ipfs-util"
|
||||
offline "gx/ipfs/QmS6mo1dPpHdYsVkm27BRZDLxpKBCiJKUH8fHX15XFfMez/go-ipfs-exchange-offline"
|
||||
|
@ -6,7 +6,7 @@ import (
|
||||
gopath "path"
|
||||
"strings"
|
||||
|
||||
path "github.com/ipfs/go-ipfs/path"
|
||||
path "gx/ipfs/QmYKNMEUK7nCVAefgXF1LVtZEZg3uRmBqiae4FJRXDNAyJ/go-path"
|
||||
|
||||
cid "gx/ipfs/QmYVNvtQkeZ6AKSwDrjQTs432QtL6umrrK41EBq3cu7iSP/go-cid"
|
||||
ipld "gx/ipfs/QmZtNq8dArGfnpCZfx2pUNY7UcjGhVp5qqwQ4hH6mpTMRQ/go-ipld-format"
|
||||
|
@ -7,7 +7,7 @@ import (
|
||||
context "context"
|
||||
|
||||
opts "github.com/ipfs/go-ipfs/namesys/opts"
|
||||
path "github.com/ipfs/go-ipfs/path"
|
||||
path "gx/ipfs/QmYKNMEUK7nCVAefgXF1LVtZEZg3uRmBqiae4FJRXDNAyJ/go-path"
|
||||
)
|
||||
|
||||
type resolver interface {
|
||||
|
@ -3,7 +3,7 @@ package namesys
|
||||
import (
|
||||
"time"
|
||||
|
||||
path "github.com/ipfs/go-ipfs/path"
|
||||
path "gx/ipfs/QmYKNMEUK7nCVAefgXF1LVtZEZg3uRmBqiae4FJRXDNAyJ/go-path"
|
||||
)
|
||||
|
||||
func (ns *mpns) cacheGet(name string) (path.Path, bool) {
|
||||
|
@ -8,7 +8,7 @@ import (
|
||||
"time"
|
||||
|
||||
opts "github.com/ipfs/go-ipfs/namesys/opts"
|
||||
path "github.com/ipfs/go-ipfs/path"
|
||||
path "gx/ipfs/QmYKNMEUK7nCVAefgXF1LVtZEZg3uRmBqiae4FJRXDNAyJ/go-path"
|
||||
isd "gx/ipfs/QmZmmuAXgX73UQmX1jRKjTGmjzq24Jinqkq8vzkBtno4uX/go-is-domain"
|
||||
)
|
||||
|
||||
|
@ -36,7 +36,7 @@ import (
|
||||
context "context"
|
||||
|
||||
opts "github.com/ipfs/go-ipfs/namesys/opts"
|
||||
path "github.com/ipfs/go-ipfs/path"
|
||||
path "gx/ipfs/QmYKNMEUK7nCVAefgXF1LVtZEZg3uRmBqiae4FJRXDNAyJ/go-path"
|
||||
|
||||
ci "gx/ipfs/Qme1knMqwt1hKZbc1BmQFmnm9f36nyQGwXxPGVpVJ9rMK5/go-libp2p-crypto"
|
||||
)
|
||||
|
@ -6,7 +6,7 @@ import (
|
||||
"time"
|
||||
|
||||
opts "github.com/ipfs/go-ipfs/namesys/opts"
|
||||
path "github.com/ipfs/go-ipfs/path"
|
||||
path "gx/ipfs/QmYKNMEUK7nCVAefgXF1LVtZEZg3uRmBqiae4FJRXDNAyJ/go-path"
|
||||
|
||||
u "gx/ipfs/QmPdKqUcHGFdeSpvjVoaTRPPstGif9GBZb5Q56RVw9o69A/go-ipfs-util"
|
||||
record "gx/ipfs/QmVsp2KdPYE6M8ryzCk5KHLo3zprcY5hBDaYx6uPCFUdxA/go-libp2p-record"
|
||||
|
@ -6,7 +6,7 @@ import (
|
||||
"time"
|
||||
|
||||
opts "github.com/ipfs/go-ipfs/namesys/opts"
|
||||
path "github.com/ipfs/go-ipfs/path"
|
||||
path "gx/ipfs/QmYKNMEUK7nCVAefgXF1LVtZEZg3uRmBqiae4FJRXDNAyJ/go-path"
|
||||
|
||||
mh "gx/ipfs/QmPnFwZ2JXKnXgMw8CdBPxn7FWh6LLdjUjxV1fKHuJnkr8/go-multihash"
|
||||
lru "gx/ipfs/QmVYxfoJQiZijTgPNHCHgHELvQpbsJNTg6Crmc3dQkj3yy/golang-lru"
|
||||
|
@ -7,8 +7,8 @@ import (
|
||||
"time"
|
||||
|
||||
opts "github.com/ipfs/go-ipfs/namesys/opts"
|
||||
path "github.com/ipfs/go-ipfs/path"
|
||||
"github.com/ipfs/go-ipfs/unixfs"
|
||||
path "gx/ipfs/QmYKNMEUK7nCVAefgXF1LVtZEZg3uRmBqiae4FJRXDNAyJ/go-path"
|
||||
|
||||
pstore "gx/ipfs/QmZR2XWVVBCtbgBWnQhWk2xcQfaR3W8faQPriAiaaj7rsr/go-libp2p-peerstore"
|
||||
offroute "gx/ipfs/QmbFRJeEmEU16y3BmKKaD4a9fm5oHsEAMHe2vSB1UnfLMi/go-ipfs-routing/offline"
|
||||
|
@ -7,7 +7,7 @@ import (
|
||||
context "context"
|
||||
|
||||
opts "github.com/ipfs/go-ipfs/namesys/opts"
|
||||
path "github.com/ipfs/go-ipfs/path"
|
||||
path "gx/ipfs/QmYKNMEUK7nCVAefgXF1LVtZEZg3uRmBqiae4FJRXDNAyJ/go-path"
|
||||
proquint "gx/ipfs/QmYnf27kzqR2cxt6LFZdrAFJuQd6785fTkBvMuEj9EeRxM/proquint"
|
||||
)
|
||||
|
||||
|
@ -7,9 +7,9 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
path "github.com/ipfs/go-ipfs/path"
|
||||
pin "github.com/ipfs/go-ipfs/pin"
|
||||
ft "github.com/ipfs/go-ipfs/unixfs"
|
||||
path "gx/ipfs/QmYKNMEUK7nCVAefgXF1LVtZEZg3uRmBqiae4FJRXDNAyJ/go-path"
|
||||
|
||||
routing "gx/ipfs/QmZ383TySJVeZWzGnWui6pRcKyYZk9VkKTuW7tmKRWk5au/go-libp2p-routing"
|
||||
proto "gx/ipfs/QmZ4Qi3GaRbjcx28Sme5eMH7RQjGkt8wHxt2a65oLaeFEV/gogo-protobuf/proto"
|
||||
|
@ -7,7 +7,7 @@ import (
|
||||
|
||||
keystore "github.com/ipfs/go-ipfs/keystore"
|
||||
namesys "github.com/ipfs/go-ipfs/namesys"
|
||||
path "github.com/ipfs/go-ipfs/path"
|
||||
path "gx/ipfs/QmYKNMEUK7nCVAefgXF1LVtZEZg3uRmBqiae4FJRXDNAyJ/go-path"
|
||||
|
||||
goprocess "gx/ipfs/QmSF8fPo3jgVBAy8fpdjjYqgG87dkJgUprRBHRd2tmfgpP/goprocess"
|
||||
gpctx "gx/ipfs/QmSF8fPo3jgVBAy8fpdjjYqgG87dkJgUprRBHRd2tmfgpP/goprocess/context"
|
||||
|
@ -10,7 +10,7 @@ import (
|
||||
mock "github.com/ipfs/go-ipfs/core/mock"
|
||||
namesys "github.com/ipfs/go-ipfs/namesys"
|
||||
. "github.com/ipfs/go-ipfs/namesys/republisher"
|
||||
path "github.com/ipfs/go-ipfs/path"
|
||||
path "gx/ipfs/QmYKNMEUK7nCVAefgXF1LVtZEZg3uRmBqiae4FJRXDNAyJ/go-path"
|
||||
|
||||
goprocess "gx/ipfs/QmSF8fPo3jgVBAy8fpdjjYqgG87dkJgUprRBHRd2tmfgpP/goprocess"
|
||||
mocknet "gx/ipfs/QmY51bqSM5XgxQZqsBrQcRkKTnCb8EKpJpR9K6Qax7Njco/go-libp2p/p2p/net/mock"
|
||||
|
@ -6,7 +6,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
path "github.com/ipfs/go-ipfs/path"
|
||||
path "gx/ipfs/QmYKNMEUK7nCVAefgXF1LVtZEZg3uRmBqiae4FJRXDNAyJ/go-path"
|
||||
|
||||
mockrouting "gx/ipfs/QmbFRJeEmEU16y3BmKKaD4a9fm5oHsEAMHe2vSB1UnfLMi/go-ipfs-routing/mock"
|
||||
testutil "gx/ipfs/QmcW4FGAt24fdK1jBgWQn3yP4R9ZLyWQqjozv9QK7epRhL/go-testutil"
|
||||
|
@ -6,7 +6,7 @@ import (
|
||||
"time"
|
||||
|
||||
opts "github.com/ipfs/go-ipfs/namesys/opts"
|
||||
path "github.com/ipfs/go-ipfs/path"
|
||||
path "gx/ipfs/QmYKNMEUK7nCVAefgXF1LVtZEZg3uRmBqiae4FJRXDNAyJ/go-path"
|
||||
|
||||
mh "gx/ipfs/QmPnFwZ2JXKnXgMw8CdBPxn7FWh6LLdjUjxV1fKHuJnkr8/go-multihash"
|
||||
dht "gx/ipfs/QmTktQYCKzQjhxF6dk5xJPRuhHn3JBiKGvMLoiDy1mYmxC/go-libp2p-kad-dht"
|
||||
|
@ -563,6 +563,12 @@
|
||||
"hash": "QmRy4Qk9hbgFX9NGJRm8rBThrA8PZhNCitMgeRYyZ67s59",
|
||||
"name": "go-merkledag",
|
||||
"version": "1.0.0"
|
||||
},
|
||||
{
|
||||
"author": "why",
|
||||
"hash": "QmYKNMEUK7nCVAefgXF1LVtZEZg3uRmBqiae4FJRXDNAyJ",
|
||||
"name": "go-path",
|
||||
"version": "1.0.1"
|
||||
}
|
||||
],
|
||||
"gxVersion": "0.10.0",
|
||||
|
181
path/path.go
181
path/path.go
@ -1,181 +0,0 @@
|
||||
// Package path contains utilities to work with ipfs paths.
|
||||
package path
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"path"
|
||||
"strings"
|
||||
|
||||
cid "gx/ipfs/QmYVNvtQkeZ6AKSwDrjQTs432QtL6umrrK41EBq3cu7iSP/go-cid"
|
||||
)
|
||||
|
||||
var (
|
||||
// ErrBadPath is returned when a given path is incorrectly formatted
|
||||
ErrBadPath = errors.New("invalid 'ipfs ref' path")
|
||||
|
||||
// ErrNoComponents is used when Paths after a protocol
|
||||
// do not contain at least one component
|
||||
ErrNoComponents = errors.New(
|
||||
"path must contain at least one component")
|
||||
)
|
||||
|
||||
// A Path represents an ipfs content path:
|
||||
// * /<cid>/path/to/file
|
||||
// * /ipfs/<cid>
|
||||
// * /ipns/<cid>/path/to/folder
|
||||
// * etc
|
||||
type Path string
|
||||
|
||||
// ^^^
|
||||
// TODO: debate making this a private struct wrapped in a public interface
|
||||
// would allow us to control creation, and cache segments.
|
||||
|
||||
// FromString safely converts a string type to a Path type.
|
||||
func FromString(s string) Path {
|
||||
return Path(s)
|
||||
}
|
||||
|
||||
// FromCid safely converts a cid.Cid type to a Path type.
|
||||
func FromCid(c *cid.Cid) Path {
|
||||
return Path("/ipfs/" + c.String())
|
||||
}
|
||||
|
||||
// Segments returns the different elements of a path
|
||||
// (elements are delimited by a /).
|
||||
func (p Path) Segments() []string {
|
||||
cleaned := path.Clean(string(p))
|
||||
segments := strings.Split(cleaned, "/")
|
||||
|
||||
// Ignore leading slash
|
||||
if len(segments[0]) == 0 {
|
||||
segments = segments[1:]
|
||||
}
|
||||
|
||||
return segments
|
||||
}
|
||||
|
||||
// String converts a path to string.
|
||||
func (p Path) String() string {
|
||||
return string(p)
|
||||
}
|
||||
|
||||
// IsJustAKey returns true if the path is of the form <key> or /ipfs/<key>, or
|
||||
// /ipld/<key>
|
||||
func (p Path) IsJustAKey() bool {
|
||||
parts := p.Segments()
|
||||
return len(parts) == 2 && (parts[0] == "ipfs" || parts[0] == "ipld")
|
||||
}
|
||||
|
||||
// PopLastSegment returns a new Path without its final segment, and the final
|
||||
// segment, separately. If there is no more to pop (the path is just a key),
|
||||
// the original path is returned.
|
||||
func (p Path) PopLastSegment() (Path, string, error) {
|
||||
|
||||
if p.IsJustAKey() {
|
||||
return p, "", nil
|
||||
}
|
||||
|
||||
segs := p.Segments()
|
||||
newPath, err := ParsePath("/" + strings.Join(segs[:len(segs)-1], "/"))
|
||||
if err != nil {
|
||||
return "", "", err
|
||||
}
|
||||
|
||||
return newPath, segs[len(segs)-1], nil
|
||||
}
|
||||
|
||||
// FromSegments returns a path given its different segments.
|
||||
func FromSegments(prefix string, seg ...string) (Path, error) {
|
||||
return ParsePath(prefix + strings.Join(seg, "/"))
|
||||
}
|
||||
|
||||
// ParsePath returns a well-formed ipfs Path.
|
||||
// The returned path will always be prefixed with /ipfs/ or /ipns/.
|
||||
// The prefix will be added if not present in the given string.
|
||||
// This function will return an error when the given string is
|
||||
// not a valid ipfs path.
|
||||
func ParsePath(txt string) (Path, error) {
|
||||
parts := strings.Split(txt, "/")
|
||||
if len(parts) == 1 {
|
||||
kp, err := ParseCidToPath(txt)
|
||||
if err == nil {
|
||||
return kp, nil
|
||||
}
|
||||
}
|
||||
|
||||
// if the path doesnt begin with a '/'
|
||||
// we expect this to start with a hash, and be an 'ipfs' path
|
||||
if parts[0] != "" {
|
||||
if _, err := ParseCidToPath(parts[0]); err != nil {
|
||||
return "", ErrBadPath
|
||||
}
|
||||
// The case when the path starts with hash without a protocol prefix
|
||||
return Path("/ipfs/" + txt), nil
|
||||
}
|
||||
|
||||
if len(parts) < 3 {
|
||||
return "", ErrBadPath
|
||||
}
|
||||
|
||||
if parts[1] == "ipfs" {
|
||||
if _, err := ParseCidToPath(parts[2]); err != nil {
|
||||
return "", err
|
||||
}
|
||||
} else if parts[1] != "ipns" && parts[1] != "ipld" { //TODO: make this smarter
|
||||
return "", ErrBadPath
|
||||
}
|
||||
|
||||
return Path(txt), nil
|
||||
}
|
||||
|
||||
// ParseCidToPath takes a CID in string form and returns a valid ipfs Path.
|
||||
func ParseCidToPath(txt string) (Path, error) {
|
||||
if txt == "" {
|
||||
return "", ErrNoComponents
|
||||
}
|
||||
|
||||
c, err := cid.Decode(txt)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return FromCid(c), nil
|
||||
}
|
||||
|
||||
// IsValid checks if a path is a valid ipfs Path.
|
||||
func (p *Path) IsValid() error {
|
||||
_, err := ParsePath(p.String())
|
||||
return err
|
||||
}
|
||||
|
||||
// Join joins strings slices using /
|
||||
func Join(pths []string) string {
|
||||
return strings.Join(pths, "/")
|
||||
}
|
||||
|
||||
// SplitList splits strings usings /
|
||||
func SplitList(pth string) []string {
|
||||
return strings.Split(pth, "/")
|
||||
}
|
||||
|
||||
// SplitAbsPath clean up and split fpath. It extracts the first component (which
|
||||
// must be a Multihash) and return it separately.
|
||||
func SplitAbsPath(fpath Path) (*cid.Cid, []string, error) {
|
||||
parts := fpath.Segments()
|
||||
if parts[0] == "ipfs" || parts[0] == "ipld" {
|
||||
parts = parts[1:]
|
||||
}
|
||||
|
||||
// if nothing, bail.
|
||||
if len(parts) == 0 {
|
||||
return nil, nil, ErrNoComponents
|
||||
}
|
||||
|
||||
c, err := cid.Decode(parts[0])
|
||||
// first element in the path is a cid
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
return c, parts[1:], nil
|
||||
}
|
@ -1,85 +0,0 @@
|
||||
package path
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestPathParsing(t *testing.T) {
|
||||
cases := map[string]bool{
|
||||
"/ipfs/QmdfTbBqBPQ7VNxZEYEj14VmRuZBkqFbiwReogJgS1zR1n": true,
|
||||
"/ipfs/QmdfTbBqBPQ7VNxZEYEj14VmRuZBkqFbiwReogJgS1zR1n/a": true,
|
||||
"/ipfs/QmdfTbBqBPQ7VNxZEYEj14VmRuZBkqFbiwReogJgS1zR1n/a/b/c/d/e/f": true,
|
||||
"/ipld/QmdfTbBqBPQ7VNxZEYEj14VmRuZBkqFbiwReogJgS1zR1n": true,
|
||||
"/ipld/QmdfTbBqBPQ7VNxZEYEj14VmRuZBkqFbiwReogJgS1zR1n/a": true,
|
||||
"/ipld/QmdfTbBqBPQ7VNxZEYEj14VmRuZBkqFbiwReogJgS1zR1n/a/b/c/d/e/f": true,
|
||||
"/ipns/QmdfTbBqBPQ7VNxZEYEj14VmRuZBkqFbiwReogJgS1zR1n/a/b/c/d/e/f": true,
|
||||
"/ipns/QmdfTbBqBPQ7VNxZEYEj14VmRuZBkqFbiwReogJgS1zR1n": true,
|
||||
"QmdfTbBqBPQ7VNxZEYEj14VmRuZBkqFbiwReogJgS1zR1n/a/b/c/d/e/f": true,
|
||||
"QmdfTbBqBPQ7VNxZEYEj14VmRuZBkqFbiwReogJgS1zR1n": true,
|
||||
"/QmdfTbBqBPQ7VNxZEYEj14VmRuZBkqFbiwReogJgS1zR1n": false,
|
||||
"/QmdfTbBqBPQ7VNxZEYEj14VmRuZBkqFbiwReogJgS1zR1n/a": false,
|
||||
"/ipfs/": false,
|
||||
"ipfs/": false,
|
||||
"ipfs/QmdfTbBqBPQ7VNxZEYEj14VmRuZBkqFbiwReogJgS1zR1n": false,
|
||||
}
|
||||
|
||||
for p, expected := range cases {
|
||||
_, err := ParsePath(p)
|
||||
valid := err == nil
|
||||
if valid != expected {
|
||||
t.Fatalf("expected %s to have valid == %t", p, expected)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestIsJustAKey(t *testing.T) {
|
||||
cases := map[string]bool{
|
||||
"QmdfTbBqBPQ7VNxZEYEj14VmRuZBkqFbiwReogJgS1zR1n": true,
|
||||
"/ipfs/QmdfTbBqBPQ7VNxZEYEj14VmRuZBkqFbiwReogJgS1zR1n": true,
|
||||
"/ipfs/QmdfTbBqBPQ7VNxZEYEj14VmRuZBkqFbiwReogJgS1zR1n/a": false,
|
||||
"/ipfs/QmdfTbBqBPQ7VNxZEYEj14VmRuZBkqFbiwReogJgS1zR1n/a/b": false,
|
||||
"/ipns/QmdfTbBqBPQ7VNxZEYEj14VmRuZBkqFbiwReogJgS1zR1n": false,
|
||||
"/ipld/QmdfTbBqBPQ7VNxZEYEj14VmRuZBkqFbiwReogJgS1zR1n/a/b": false,
|
||||
"/ipld/QmdfTbBqBPQ7VNxZEYEj14VmRuZBkqFbiwReogJgS1zR1n": true,
|
||||
}
|
||||
|
||||
for p, expected := range cases {
|
||||
path, err := ParsePath(p)
|
||||
if err != nil {
|
||||
t.Fatalf("ParsePath failed to parse \"%s\", but should have succeeded", p)
|
||||
}
|
||||
result := path.IsJustAKey()
|
||||
if result != expected {
|
||||
t.Fatalf("expected IsJustAKey(%s) to return %v, not %v", p, expected, result)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestPopLastSegment(t *testing.T) {
|
||||
cases := map[string][]string{
|
||||
"QmdfTbBqBPQ7VNxZEYEj14VmRuZBkqFbiwReogJgS1zR1n": []string{"/ipfs/QmdfTbBqBPQ7VNxZEYEj14VmRuZBkqFbiwReogJgS1zR1n", ""},
|
||||
"/ipfs/QmdfTbBqBPQ7VNxZEYEj14VmRuZBkqFbiwReogJgS1zR1n": []string{"/ipfs/QmdfTbBqBPQ7VNxZEYEj14VmRuZBkqFbiwReogJgS1zR1n", ""},
|
||||
"/ipfs/QmdfTbBqBPQ7VNxZEYEj14VmRuZBkqFbiwReogJgS1zR1n/a": []string{"/ipfs/QmdfTbBqBPQ7VNxZEYEj14VmRuZBkqFbiwReogJgS1zR1n", "a"},
|
||||
"/ipfs/QmdfTbBqBPQ7VNxZEYEj14VmRuZBkqFbiwReogJgS1zR1n/a/b": []string{"/ipfs/QmdfTbBqBPQ7VNxZEYEj14VmRuZBkqFbiwReogJgS1zR1n/a", "b"},
|
||||
"/ipns/QmdfTbBqBPQ7VNxZEYEj14VmRuZBkqFbiwReogJgS1zR1n/x/y/z": []string{"/ipns/QmdfTbBqBPQ7VNxZEYEj14VmRuZBkqFbiwReogJgS1zR1n/x/y", "z"},
|
||||
"/ipld/QmdfTbBqBPQ7VNxZEYEj14VmRuZBkqFbiwReogJgS1zR1n/x/y/z": []string{"/ipld/QmdfTbBqBPQ7VNxZEYEj14VmRuZBkqFbiwReogJgS1zR1n/x/y", "z"},
|
||||
}
|
||||
|
||||
for p, expected := range cases {
|
||||
path, err := ParsePath(p)
|
||||
if err != nil {
|
||||
t.Fatalf("ParsePath failed to parse \"%s\", but should have succeeded", p)
|
||||
}
|
||||
head, tail, err := path.PopLastSegment()
|
||||
if err != nil {
|
||||
t.Fatalf("PopLastSegment failed, but should have succeeded: %s", err)
|
||||
}
|
||||
headStr := head.String()
|
||||
if headStr != expected[0] {
|
||||
t.Fatalf("expected head of PopLastSegment(%s) to return %v, not %v", p, expected[0], headStr)
|
||||
}
|
||||
if tail != expected[1] {
|
||||
t.Fatalf("expected tail of PopLastSegment(%s) to return %v, not %v", p, expected[1], tail)
|
||||
}
|
||||
}
|
||||
}
|
@ -1,199 +0,0 @@
|
||||
// Package resolver implements utilities for resolving paths within ipfs.
|
||||
package resolver
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
path "github.com/ipfs/go-ipfs/path"
|
||||
dag "gx/ipfs/QmRy4Qk9hbgFX9NGJRm8rBThrA8PZhNCitMgeRYyZ67s59/go-merkledag"
|
||||
|
||||
cid "gx/ipfs/QmYVNvtQkeZ6AKSwDrjQTs432QtL6umrrK41EBq3cu7iSP/go-cid"
|
||||
ipld "gx/ipfs/QmZtNq8dArGfnpCZfx2pUNY7UcjGhVp5qqwQ4hH6mpTMRQ/go-ipld-format"
|
||||
logging "gx/ipfs/QmcVVHfdyv15GVPk7NrxdWjh2hLVccXnoD8j2tyQShiXJb/go-log"
|
||||
)
|
||||
|
||||
var log = logging.Logger("pathresolv")
|
||||
|
||||
// ErrNoComponents is used when Paths after a protocol
|
||||
// do not contain at least one component
|
||||
var ErrNoComponents = errors.New(
|
||||
"path must contain at least one component")
|
||||
|
||||
// ErrNoLink is returned when a link is not found in a path
|
||||
type ErrNoLink struct {
|
||||
Name string
|
||||
Node *cid.Cid
|
||||
}
|
||||
|
||||
// Error implements the Error interface for ErrNoLink with a useful
|
||||
// human readable message.
|
||||
func (e ErrNoLink) Error() string {
|
||||
return fmt.Sprintf("no link named %q under %s", e.Name, e.Node.String())
|
||||
}
|
||||
|
||||
// ResolveOnce resolves path through a single node
|
||||
type ResolveOnce func(ctx context.Context, ds ipld.NodeGetter, nd ipld.Node, names []string) (*ipld.Link, []string, error)
|
||||
|
||||
// Resolver provides path resolution to IPFS
|
||||
// It has a pointer to a DAGService, which is uses to resolve nodes.
|
||||
// TODO: now that this is more modular, try to unify this code with the
|
||||
// the resolvers in namesys
|
||||
type Resolver struct {
|
||||
DAG ipld.NodeGetter
|
||||
|
||||
ResolveOnce ResolveOnce
|
||||
}
|
||||
|
||||
// NewBasicResolver constructs a new basic resolver.
|
||||
func NewBasicResolver(ds ipld.DAGService) *Resolver {
|
||||
return &Resolver{
|
||||
DAG: ds,
|
||||
ResolveOnce: ResolveSingle,
|
||||
}
|
||||
}
|
||||
|
||||
// ResolveToLastNode walks the given path and returns the ipld.Node
|
||||
// referenced by the last element in it.
|
||||
func (r *Resolver) ResolveToLastNode(ctx context.Context, fpath path.Path) (ipld.Node, []string, error) {
|
||||
c, p, err := path.SplitAbsPath(fpath)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
nd, err := r.DAG.Get(ctx, c)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
for len(p) > 0 {
|
||||
lnk, rest, err := r.ResolveOnce(ctx, r.DAG, nd, p)
|
||||
|
||||
// Note: have to drop the error here as `ResolveOnce` doesn't handle 'leaf'
|
||||
// paths (so e.g. for `echo '{"foo":123}' | ipfs dag put` we wouldn't be
|
||||
// able to resolve `zdpu[...]/foo`)
|
||||
if lnk == nil {
|
||||
break
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
next, err := lnk.GetNode(ctx, r.DAG)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
nd = next
|
||||
p = rest
|
||||
}
|
||||
|
||||
if len(p) == 0 {
|
||||
return nd, nil, nil
|
||||
}
|
||||
|
||||
// Confirm the path exists within the object
|
||||
val, rest, err := nd.Resolve(p)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
if len(rest) > 0 {
|
||||
return nil, nil, errors.New("path failed to resolve fully")
|
||||
}
|
||||
switch val.(type) {
|
||||
case *ipld.Link:
|
||||
return nil, nil, errors.New("inconsistent ResolveOnce / nd.Resolve")
|
||||
default:
|
||||
return nd, p, nil
|
||||
}
|
||||
}
|
||||
|
||||
// ResolvePath fetches the node for given path. It returns the last item
|
||||
// returned by ResolvePathComponents.
|
||||
func (r *Resolver) ResolvePath(ctx context.Context, fpath path.Path) (ipld.Node, error) {
|
||||
// validate path
|
||||
if err := fpath.IsValid(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
nodes, err := r.ResolvePathComponents(ctx, fpath)
|
||||
if err != nil || nodes == nil {
|
||||
return nil, err
|
||||
}
|
||||
return nodes[len(nodes)-1], err
|
||||
}
|
||||
|
||||
// ResolveSingle simply resolves one hop of a path through a graph with no
|
||||
// extra context (does not opaquely resolve through sharded nodes)
|
||||
func ResolveSingle(ctx context.Context, ds ipld.NodeGetter, nd ipld.Node, names []string) (*ipld.Link, []string, error) {
|
||||
return nd.ResolveLink(names)
|
||||
}
|
||||
|
||||
// ResolvePathComponents fetches the nodes for each segment of the given path.
|
||||
// It uses the first path component as a hash (key) of the first node, then
|
||||
// resolves all other components walking the links, with ResolveLinks.
|
||||
func (r *Resolver) ResolvePathComponents(ctx context.Context, fpath path.Path) ([]ipld.Node, error) {
|
||||
evt := log.EventBegin(ctx, "resolvePathComponents", logging.LoggableMap{"fpath": fpath})
|
||||
defer evt.Done()
|
||||
|
||||
h, parts, err := path.SplitAbsPath(fpath)
|
||||
if err != nil {
|
||||
evt.Append(logging.LoggableMap{"error": err.Error()})
|
||||
return nil, err
|
||||
}
|
||||
|
||||
log.Debug("resolve dag get")
|
||||
nd, err := r.DAG.Get(ctx, h)
|
||||
if err != nil {
|
||||
evt.Append(logging.LoggableMap{"error": err.Error()})
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return r.ResolveLinks(ctx, nd, parts)
|
||||
}
|
||||
|
||||
// ResolveLinks iteratively resolves names by walking the link hierarchy.
|
||||
// Every node is fetched from the DAGService, resolving the next name.
|
||||
// Returns the list of nodes forming the path, starting with ndd. This list is
|
||||
// guaranteed never to be empty.
|
||||
//
|
||||
// ResolveLinks(nd, []string{"foo", "bar", "baz"})
|
||||
// would retrieve "baz" in ("bar" in ("foo" in nd.Links).Links).Links
|
||||
func (r *Resolver) ResolveLinks(ctx context.Context, ndd ipld.Node, names []string) ([]ipld.Node, error) {
|
||||
|
||||
evt := log.EventBegin(ctx, "resolveLinks", logging.LoggableMap{"names": names})
|
||||
defer evt.Done()
|
||||
result := make([]ipld.Node, 0, len(names)+1)
|
||||
result = append(result, ndd)
|
||||
nd := ndd // dup arg workaround
|
||||
|
||||
// for each of the path components
|
||||
for len(names) > 0 {
|
||||
var cancel context.CancelFunc
|
||||
ctx, cancel = context.WithTimeout(ctx, time.Minute)
|
||||
defer cancel()
|
||||
|
||||
lnk, rest, err := r.ResolveOnce(ctx, r.DAG, nd, names)
|
||||
if err == dag.ErrLinkNotFound {
|
||||
evt.Append(logging.LoggableMap{"error": err.Error()})
|
||||
return result, ErrNoLink{Name: names[0], Node: nd.Cid()}
|
||||
} else if err != nil {
|
||||
evt.Append(logging.LoggableMap{"error": err.Error()})
|
||||
return result, err
|
||||
}
|
||||
|
||||
nextnode, err := lnk.GetNode(ctx, r.DAG)
|
||||
if err != nil {
|
||||
evt.Append(logging.LoggableMap{"error": err.Error()})
|
||||
return result, err
|
||||
}
|
||||
|
||||
nd = nextnode
|
||||
result = append(result, nextnode)
|
||||
names = rest
|
||||
}
|
||||
return result, nil
|
||||
}
|
@ -1,70 +0,0 @@
|
||||
package resolver_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
path "github.com/ipfs/go-ipfs/path"
|
||||
"github.com/ipfs/go-ipfs/path/resolver"
|
||||
merkledag "gx/ipfs/QmRy4Qk9hbgFX9NGJRm8rBThrA8PZhNCitMgeRYyZ67s59/go-merkledag"
|
||||
dagmock "gx/ipfs/QmRy4Qk9hbgFX9NGJRm8rBThrA8PZhNCitMgeRYyZ67s59/go-merkledag/test"
|
||||
|
||||
util "gx/ipfs/QmPdKqUcHGFdeSpvjVoaTRPPstGif9GBZb5Q56RVw9o69A/go-ipfs-util"
|
||||
ipld "gx/ipfs/QmZtNq8dArGfnpCZfx2pUNY7UcjGhVp5qqwQ4hH6mpTMRQ/go-ipld-format"
|
||||
)
|
||||
|
||||
func randNode() *merkledag.ProtoNode {
|
||||
node := new(merkledag.ProtoNode)
|
||||
node.SetData(make([]byte, 32))
|
||||
util.NewTimeSeededRand().Read(node.Data())
|
||||
return node
|
||||
}
|
||||
|
||||
func TestRecurivePathResolution(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
dagService := dagmock.Mock()
|
||||
|
||||
a := randNode()
|
||||
b := randNode()
|
||||
c := randNode()
|
||||
|
||||
err := b.AddNodeLink("grandchild", c)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
err = a.AddNodeLink("child", b)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
for _, n := range []ipld.Node{a, b, c} {
|
||||
err = dagService.Add(ctx, n)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
aKey := a.Cid()
|
||||
|
||||
segments := []string{aKey.String(), "child", "grandchild"}
|
||||
p, err := path.FromSegments("/ipfs/", segments...)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
resolver := resolver.NewBasicResolver(dagService)
|
||||
node, err := resolver.ResolvePath(ctx, p)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
cKey := c.Cid()
|
||||
key := node.Cid()
|
||||
if key.String() != cKey.String() {
|
||||
t.Fatal(fmt.Errorf(
|
||||
"recursive path resolution failed for %s: %s != %s",
|
||||
p.String(), key.String(), cKey.String()))
|
||||
}
|
||||
}
|
@ -10,9 +10,9 @@ import (
|
||||
|
||||
"github.com/ipfs/go-ipfs/dagutils"
|
||||
importer "github.com/ipfs/go-ipfs/importer"
|
||||
path "github.com/ipfs/go-ipfs/path"
|
||||
uio "github.com/ipfs/go-ipfs/unixfs/io"
|
||||
dag "gx/ipfs/QmRy4Qk9hbgFX9NGJRm8rBThrA8PZhNCitMgeRYyZ67s59/go-merkledag"
|
||||
path "gx/ipfs/QmYKNMEUK7nCVAefgXF1LVtZEZg3uRmBqiae4FJRXDNAyJ/go-path"
|
||||
|
||||
chunker "gx/ipfs/QmVDjhUMtkRskBFAVNwyXuLSKbeAya7JKPnzAxMKDaK4x4/go-ipfs-chunker"
|
||||
ipld "gx/ipfs/QmZtNq8dArGfnpCZfx2pUNY7UcjGhVp5qqwQ4hH6mpTMRQ/go-ipld-format"
|
||||
|
Reference in New Issue
Block a user