@cryptotaxi247 / kubo / commits / 5c31db3a3

commands: remove several deprecated commands

Removes the following commands: ipfs tar, ipfs urlstore, ipfs repo fsck, ipfs file ls, ipfs dns.

Henrique Dias committed Dec 12, 2023 at 18:21 UTC 5c31db3a3d189dc1c85ffc74420358d81de25d28
15 files changed +30 -1027
CHANGELOG.md
+1
@@ -1,5 +1,6 @@
1 # Kubo Changelogs
2
3 +- [v0.26](docs/changelogs/v0.26.md)
4 - [v0.25](docs/changelogs/v0.25.md)
5 - [v0.24](docs/changelogs/v0.24.md)
6 - [v0.23](docs/changelogs/v0.23.md)
core/commands/commands_test.go
-10
@@ -31,7 +31,6 @@ func TestROCommands(t *testing.T) {
31 "/dag/resolve",
32 "/dag/stat",
33 "/dag/export",
34 - "/dns",
34 "/get",
35 "/ls",
36 "/name",
@@ -136,9 +135,6 @@ func TestCommands(t *testing.T) {
135 "/diag/cmds/set-time",
136 "/diag/profile",
137 "/diag/sys",
139 - "/dns",
140 - "/file",
141 - "/file/ls",
138 "/files",
139 "/files/chcid",
140 "/files/cp",
@@ -229,7 +225,6 @@ func TestCommands(t *testing.T) {
225 "/refs",
226 "/refs/local",
227 "/repo",
232 - "/repo/fsck",
228 "/repo/gc",
229 "/repo/migrate",
230 "/repo/stat",
@@ -259,12 +254,7 @@ func TestCommands(t *testing.T) {
254 "/swarm/peering/ls",
255 "/swarm/peering/rm",
256 "/swarm/resources",
262 - "/tar",
263 - "/tar/add",
264 - "/tar/cat",
257 "/update",
266 - "/urlstore",
267 - "/urlstore/add",
258 "/version",
259 "/version/deps",
260 }
core/commands/dns.go deleted
-78
@@ -1,78 +0,0 @@
1 -package commands
2 -
3 -import (
4 - "fmt"
5 - "io"
6 - "strings"
7 -
8 - namesys "github.com/ipfs/boxo/namesys"
9 - "github.com/ipfs/boxo/path"
10 - cmdenv "github.com/ipfs/kubo/core/commands/cmdenv"
11 - ncmd "github.com/ipfs/kubo/core/commands/name"
12 -
13 - cmds "github.com/ipfs/go-ipfs-cmds"
14 -)
15 -
16 -const (
17 - dnsRecursiveOptionName = "recursive"
18 -)
19 -
20 -var DNSCmd = &cmds.Command{
21 - Status: cmds.Deprecated, // https://github.com/ipfs/kubo/issues/8607
22 - Helptext: cmds.HelpText{
23 - Tagline: "Resolve DNSLink records. Deprecated: Use 'ipfs resolve /ipns/domain-name' instead.",
24 - ShortDescription: `
25 -This command can only recursively resolve DNSLink TXT records.
26 -It will fail to recursively resolve through IPNS keys etc.
27 -
28 -DEPRECATED: superseded by 'ipfs resolve'
29 -
30 -For general-purpose recursive resolution, use 'ipfs resolve -r'.
31 -It will work across multiple DNSLinks and IPNS keys.
32 -`,
33 - },
34 -
35 - Arguments: []cmds.Argument{
36 - cmds.StringArg("domain-name", true, false, "The domain-name name to resolve.").EnableStdin(),
37 - },
38 - Options: []cmds.Option{
39 - cmds.BoolOption(dnsRecursiveOptionName, "r", "Resolve until the result is not a DNS link.").WithDefault(true),
40 - },
41 - Run: func(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environment) error {
42 - node, err := cmdenv.GetNode(env)
43 - if err != nil {
44 - return err
45 - }
46 -
47 - recursive, _ := req.Options[dnsRecursiveOptionName].(bool)
48 - name := req.Arguments[0]
49 - resolver := namesys.NewDNSResolver(node.DNSResolver.LookupTXT)
50 -
51 - var routing []namesys.ResolveOption
52 - if !recursive {
53 - routing = append(routing, namesys.ResolveWithDepth(1))
54 - }
55 -
56 - if !strings.HasPrefix(name, "/ipns/") {
57 - name = "/ipns/" + name
58 - }
59 -
60 - p, err := path.NewPath(name)
61 - if err != nil {
62 - return err
63 - }
64 -
65 - val, err := resolver.Resolve(req.Context, p, routing...)
66 - if err != nil && (recursive || err != namesys.ErrResolveRecursion) {
67 - return err
68 - }
69 - return cmds.EmitOnce(res, &ncmd.ResolvedPath{Path: val.Path.String()})
70 - },
71 - Encoders: cmds.EncoderMap{
72 - cmds.Text: cmds.MakeTypedEncoder(func(req *cmds.Request, w io.Writer, out *ncmd.ResolvedPath) error {
73 - fmt.Fprintln(w, cmdenv.EscNonPrint(out.Path))
74 - return nil
75 - }),
76 - },
77 - Type: ncmd.ResolvedPath{},
78 -}
core/commands/repo.go
-22
@@ -39,7 +39,6 @@ var RepoCmd = &cmds.Command{
39 Subcommands: map[string]*cmds.Command{
40 "stat": repoStatCmd,
41 "gc": repoGcCmd,
42 - "fsck": repoFsckCmd,
42 "version": repoVersionCmd,
43 "verify": repoVerifyCmd,
44 "migrate": repoMigrateCmd,
@@ -227,27 +226,6 @@ Version string The repo version.
226 },
227 }
228
230 -var repoFsckCmd = &cmds.Command{
231 - Status: cmds.Deprecated, // https://github.com/ipfs/kubo/issues/6435
232 - Helptext: cmds.HelpText{
233 - Tagline: "Remove repo lockfiles.",
234 - ShortDescription: `
235 -'ipfs repo fsck' is now a no-op.
236 -`,
237 - },
238 - NoRemote: true,
239 - Run: func(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environment) error {
240 - return cmds.EmitOnce(res, &MessageOutput{"`ipfs repo fsck` is deprecated and does nothing.\n"})
241 - },
242 - Type: MessageOutput{},
243 - Encoders: cmds.EncoderMap{
244 - cmds.Text: cmds.MakeTypedEncoder(func(req *cmds.Request, w io.Writer, out *MessageOutput) error {
245 - fmt.Fprintf(w, out.Message)
246 - return nil
247 - }),
248 - },
249 -}
250 -
229 type VerifyProgress struct {
230 Msg string
231 Progress int
core/commands/root.go
-6
@@ -8,7 +8,6 @@ import (
8 name "github.com/ipfs/kubo/core/commands/name"
9 ocmd "github.com/ipfs/kubo/core/commands/object"
10 "github.com/ipfs/kubo/core/commands/pin"
11 - unixfs "github.com/ipfs/kubo/core/commands/unixfs"
11
12 cmds "github.com/ipfs/go-ipfs-cmds"
13 logging "github.com/ipfs/go-log"
@@ -143,7 +142,6 @@ var rootSubcommands = map[string]*cmds.Command{
142 "dht": DhtCmd,
143 "routing": RoutingCmd,
144 "diag": DiagCmd,
146 - "dns": DNSCmd,
145 "id": IDCmd,
146 "key": KeyCmd,
147 "log": LogCmd,
@@ -157,10 +155,7 @@ var rootSubcommands = map[string]*cmds.Command{
155 "refs": RefsCmd,
156 "resolve": ResolveCmd,
157 "swarm": SwarmCmd,
160 - "tar": TarCmd,
161 - "file": unixfs.UnixFSCmd,
158 "update": ExternalBinary("Please see https://github.com/ipfs/ipfs-update/blob/master/README.md#install for installation instructions."),
163 - "urlstore": urlStoreCmd,
159 "version": VersionCmd,
160 "shutdown": daemonShutdownCmd,
161 "cid": CidCmd,
@@ -188,7 +183,6 @@ var rootROSubcommands = map[string]*cmds.Command{
183 },
184 },
185 "get": GetCmd,
191 - "dns": DNSCmd,
186 "ls": LsCmd,
187 "name": {
188 Subcommands: map[string]*cmds.Command{
core/commands/tar.go deleted
-118
@@ -1,118 +0,0 @@
1 -package commands
2 -
3 -import (
4 - "fmt"
5 - "io"
6 -
7 - cmds "github.com/ipfs/go-ipfs-cmds"
8 - "github.com/ipfs/kubo/core/commands/cmdenv"
9 - "github.com/ipfs/kubo/core/commands/cmdutils"
10 - tar "github.com/ipfs/kubo/tar"
11 -
12 - dag "github.com/ipfs/boxo/ipld/merkledag"
13 -)
14 -
15 -var TarCmd = &cmds.Command{
16 - Status: cmds.Deprecated, // https://github.com/ipfs/kubo/issues/7951
17 - Helptext: cmds.HelpText{
18 - Tagline: "Utility functions for tar files in ipfs.",
19 - },
20 -
21 - Subcommands: map[string]*cmds.Command{
22 - "add": tarAddCmd,
23 - "cat": tarCatCmd,
24 - },
25 -}
26 -
27 -var tarAddCmd = &cmds.Command{
28 - Status: cmds.Deprecated, // https://github.com/ipfs/kubo/issues/7951
29 - Helptext: cmds.HelpText{
30 - Tagline: "Import a tar file into IPFS.",
31 - ShortDescription: `
32 -'ipfs tar add' will parse a tar file and create a merkledag structure to
33 -represent it.
34 -`,
35 - },
36 -
37 - Arguments: []cmds.Argument{
38 - cmds.FileArg("file", true, false, "Tar file to add.").EnableStdin(),
39 - },
40 - Run: func(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environment) error {
41 - api, err := cmdenv.GetApi(env, req)
42 - if err != nil {
43 - return err
44 - }
45 -
46 - enc, err := cmdenv.GetCidEncoder(req)
47 - if err != nil {
48 - return err
49 - }
50 -
51 - it := req.Files.Entries()
52 - file, err := cmdenv.GetFileArg(it)
53 - if err != nil {
54 - return err
55 - }
56 -
57 - node, err := tar.ImportTar(req.Context, file, api.Dag())
58 - if err != nil {
59 - return err
60 - }
61 -
62 - c := node.Cid()
63 -
64 - return cmds.EmitOnce(res, &AddEvent{
65 - Name: it.Name(),
66 - Hash: enc.Encode(c),
67 - })
68 - },
69 - Type: AddEvent{},
70 - Encoders: cmds.EncoderMap{
71 - cmds.Text: cmds.MakeTypedEncoder(func(req *cmds.Request, w io.Writer, out *AddEvent) error {
72 - fmt.Fprintln(w, out.Hash)
73 - return nil
74 - }),
75 - },
76 -}
77 -
78 -var tarCatCmd = &cmds.Command{
79 - Status: cmds.Deprecated, // https://github.com/ipfs/kubo/issues/7951
80 - Helptext: cmds.HelpText{
81 - Tagline: "Export a tar file from IPFS.",
82 - ShortDescription: `
83 -'ipfs tar cat' will export a tar file from a previously imported one in IPFS.
84 -`,
85 - },
86 -
87 - Arguments: []cmds.Argument{
88 - cmds.StringArg("path", true, false, "ipfs path of archive to export.").EnableStdin(),
89 - },
90 - Run: func(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environment) error {
91 - api, err := cmdenv.GetApi(env, req)
92 - if err != nil {
93 - return err
94 - }
95 -
96 - p, err := cmdutils.PathOrCidPath(req.Arguments[0])
97 - if err != nil {
98 - return err
99 - }
100 -
101 - root, err := api.ResolveNode(req.Context, p)
102 - if err != nil {
103 - return err
104 - }
105 -
106 - rootpb, ok := root.(*dag.ProtoNode)
107 - if !ok {
108 - return dag.ErrNotProtobuf
109 - }
110 -
111 - r, err := tar.ExportTar(req.Context, rootpb, api.Dag())
112 - if err != nil {
113 - return err
114 - }
115 -
116 - return res.Emit(r)
117 - },
118 -}
core/commands/unixfs/ls.go deleted
-236
@@ -1,236 +0,0 @@
1 -package unixfs
2 -
3 -import (
4 - "fmt"
5 - "io"
6 - "sort"
7 - "text/tabwriter"
8 -
9 - cmdenv "github.com/ipfs/kubo/core/commands/cmdenv"
10 - "github.com/ipfs/kubo/core/commands/cmdutils"
11 -
12 - merkledag "github.com/ipfs/boxo/ipld/merkledag"
13 - unixfs "github.com/ipfs/boxo/ipld/unixfs"
14 - cmds "github.com/ipfs/go-ipfs-cmds"
15 -)
16 -
17 -type LsLink struct {
18 - Name, Hash string
19 - Size uint64
20 - Type string
21 -}
22 -
23 -type LsObject struct {
24 - Hash string
25 - Size uint64
26 - Type string
27 - Links []LsLink
28 -}
29 -
30 -type LsOutput struct {
31 - Arguments map[string]string
32 - Objects map[string]*LsObject
33 -}
34 -
35 -var LsCmd = &cmds.Command{
36 - Status: cmds.Deprecated, // https://github.com/ipfs/kubo/pull/7755
37 - Helptext: cmds.HelpText{
38 - Tagline: "List directory contents for Unix filesystem objects. Deprecated: Use 'ipfs ls' and 'ipfs files ls' instead.",
39 - ShortDescription: `
40 -Displays the contents of an IPFS or IPNS object(s) at the given path.
41 -
42 -The JSON output contains size information. For files, the child size
43 -is the total size of the file contents. For directories, the child
44 -size is the IPFS link size.
45 -
46 -This functionality is deprecated, and will be removed in future versions as it duplicates the functionality of 'ipfs ls'.
47 -If possible, please use 'ipfs ls' instead.
48 -`,
49 - LongDescription: `
50 -Displays the contents of an IPFS or IPNS object(s) at the given path.
51 -
52 -The JSON output contains size information. For files, the child size
53 -is the total size of the file contents. For directories, the child
54 -size is the IPFS link size.
55 -
56 -The path can be a prefixless ref; in this case, we assume it to be an
57 -/ipfs ref and not /ipns.
58 -
59 -Example:
60 -
61 - > ipfs file ls QmW2WQi7j6c7UgJTarActp7tDNikE4B2qXtFCfLPdsgaTQ
62 - cat.jpg
63 - > ipfs file ls /ipfs/QmW2WQi7j6c7UgJTarActp7tDNikE4B2qXtFCfLPdsgaTQ
64 - cat.jpg
65 -
66 -This functionality is deprecated, and will be removed in future versions as it duplicates the functionality of 'ipfs ls'.
67 -If possible, please use 'ipfs ls' instead.
68 -`,
69 - },
70 -
71 - Arguments: []cmds.Argument{
72 - cmds.StringArg("ipfs-path", true, true, "The path to the IPFS object(s) to list links from.").EnableStdin(),
73 - },
74 - Run: func(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environment) error {
75 - nd, err := cmdenv.GetNode(env)
76 - if err != nil {
77 - return err
78 - }
79 -
80 - api, err := cmdenv.GetApi(env, req)
81 - if err != nil {
82 - return err
83 - }
84 -
85 - if err := req.ParseBodyArgs(); err != nil {
86 - return err
87 - }
88 -
89 - paths := req.Arguments
90 -
91 - output := LsOutput{
92 - Arguments: map[string]string{},
93 - Objects: map[string]*LsObject{},
94 - }
95 -
96 - for _, p := range paths {
97 - ctx := req.Context
98 -
99 - pth, err := cmdutils.PathOrCidPath(p)
100 - if err != nil {
101 - return err
102 - }
103 -
104 - merkleNode, err := api.ResolveNode(ctx, pth)
105 - if err != nil {
106 - return err
107 - }
108 -
109 - c := merkleNode.Cid()
110 -
111 - hash := c.String()
112 - output.Arguments[p] = hash
113 -
114 - if _, ok := output.Objects[hash]; ok {
115 - // duplicate argument for an already-listed node
116 - continue
117 - }
118 -
119 - ndpb, ok := merkleNode.(*merkledag.ProtoNode)
120 - if !ok {
121 - return merkledag.ErrNotProtobuf
122 - }
123 -
124 - unixFSNode, err := unixfs.FSNodeFromBytes(ndpb.Data())
125 - if err != nil {
126 - return err
127 - }
128 -
129 - t := unixFSNode.Type()
130 -
131 - output.Objects[hash] = &LsObject{
132 - Hash: c.String(),
133 - Type: t.String(),
134 - Size: unixFSNode.FileSize(),
135 - }
136 -
137 - switch t {
138 - case unixfs.TFile:
139 - break
140 - case unixfs.THAMTShard:
141 - // We need a streaming ls API for this.
142 - return fmt.Errorf("cannot list large directories yet")
143 - case unixfs.TDirectory:
144 - links := make([]LsLink, len(merkleNode.Links()))
145 - output.Objects[hash].Links = links
146 - for i, link := range merkleNode.Links() {
147 - linkNode, err := link.GetNode(ctx, nd.DAG)
148 - if err != nil {
149 - return err
150 - }
151 - lnpb, ok := linkNode.(*merkledag.ProtoNode)
152 - if !ok {
153 - return merkledag.ErrNotProtobuf
154 - }
155 -
156 - d, err := unixfs.FSNodeFromBytes(lnpb.Data())
157 - if err != nil {
158 - return err
159 - }
160 - t := d.Type()
161 - lsLink := LsLink{
162 - Name: link.Name,
163 - Hash: link.Cid.String(),
164 - Type: t.String(),
165 - }
166 - if t == unixfs.TFile {
167 - lsLink.Size = d.FileSize()
168 - } else {
169 - lsLink.Size = link.Size
170 - }
171 - links[i] = lsLink
172 - }
173 - case unixfs.TSymlink:
174 - return fmt.Errorf("cannot list symlinks yet")
175 - default:
176 - return fmt.Errorf("unrecognized type: %s", t)
177 - }
178 - }
179 -
180 - return cmds.EmitOnce(res, &output)
181 - },
182 - Encoders: cmds.EncoderMap{
183 - cmds.Text: cmds.MakeTypedEncoder(func(req *cmds.Request, w io.Writer, out *LsOutput) error {
184 - tw := tabwriter.NewWriter(w, 1, 2, 1, ' ', 0)
185 -
186 - nonDirectories := []string{}
187 - directories := []string{}
188 - for argument, hash := range out.Arguments {
189 - object, ok := out.Objects[hash]
190 - if !ok {
191 - return fmt.Errorf("unresolved hash: %s", hash)
192 - }
193 -
194 - if object.Type == "Directory" {
195 - directories = append(directories, argument)
196 - } else {
197 - nonDirectories = append(nonDirectories, argument)
198 - }
199 - }
200 - sort.Strings(nonDirectories)
201 - sort.Strings(directories)
202 -
203 - for _, argument := range nonDirectories {
204 - fmt.Fprintf(tw, "%s\n", argument)
205 - }
206 -
207 - seen := map[string]bool{}
208 - for i, argument := range directories {
209 - hash := out.Arguments[argument]
210 - if _, ok := seen[hash]; ok {
211 - continue
212 - }
213 - seen[hash] = true
214 -
215 - object := out.Objects[hash]
216 - if i > 0 || len(nonDirectories) > 0 {
217 - fmt.Fprintln(tw)
218 - }
219 - if len(out.Arguments) > 1 {
220 - for _, arg := range directories[i:] {
221 - if out.Arguments[arg] == hash {
222 - fmt.Fprintf(tw, "%s:\n", cmdenv.EscNonPrint(arg))
223 - }
224 - }
225 - }
226 - for _, link := range object.Links {
227 - fmt.Fprintf(tw, "%s\n", cmdenv.EscNonPrint(link.Name))
228 - }
229 - }
230 - tw.Flush()
231 -
232 - return nil
233 - }),
234 - },
235 - Type: LsOutput{},
236 -}
core/commands/unixfs/unixfs.go deleted
-20
@@ -1,20 +0,0 @@
1 -package unixfs
2 -
3 -import (
4 - cmds "github.com/ipfs/go-ipfs-cmds"
5 -)
6 -
7 -var UnixFSCmd = &cmds.Command{
8 - Status: cmds.Deprecated, // https://github.com/ipfs/kubo/pull/7755
9 - Helptext: cmds.HelpText{
10 - Tagline: "Interact with IPFS objects representing Unix filesystems.",
11 - ShortDescription: `
12 -Old interface to file systems represented by UnixFS.
13 -Superseded by modern alternatives: 'ipfs ls' and 'ipfs files'
14 -`,
15 - },
16 -
17 - Subcommands: map[string]*cmds.Command{
18 - "ls": LsCmd,
19 - },
20 -}
core/commands/urlstore.go deleted
-105
@@ -1,105 +0,0 @@
1 -package commands
2 -
3 -import (
4 - "fmt"
5 - "io"
6 - "net/url"
7 -
8 - filestore "github.com/ipfs/boxo/filestore"
9 - cmdenv "github.com/ipfs/kubo/core/commands/cmdenv"
10 -
11 - "github.com/ipfs/boxo/files"
12 - cmds "github.com/ipfs/go-ipfs-cmds"
13 - "github.com/ipfs/kubo/core/coreiface/options"
14 -)
15 -
16 -var urlStoreCmd = &cmds.Command{
17 - Helptext: cmds.HelpText{
18 - Tagline: "Interact with urlstore.",
19 - },
20 - Subcommands: map[string]*cmds.Command{
21 - "add": urlAdd,
22 - },
23 -}
24 -
25 -var urlAdd = &cmds.Command{
26 - Status: cmds.Deprecated,
27 - Helptext: cmds.HelpText{
28 - Tagline: "Add URL via urlstore.",
29 - LongDescription: `
30 -DEPRECATED: Use 'ipfs add --nocopy --cid-version=1 URL'.
31 -
32 -Add URLs to ipfs without storing the data locally.
33 -
34 -The URL provided must be stable and ideally on a web server under your
35 -control.
36 -
37 -The file is added using raw-leaves but otherwise using the default
38 -settings for 'ipfs add'.
39 -`,
40 - },
41 - Options: []cmds.Option{
42 - cmds.BoolOption(trickleOptionName, "t", "Use trickle-dag format for dag generation."),
43 - cmds.BoolOption(pinOptionName, "Pin this object when adding.").WithDefault(true),
44 - },
45 - Arguments: []cmds.Argument{
46 - cmds.StringArg("url", true, false, "URL to add to IPFS"),
47 - },
48 - Type: &BlockStat{},
49 -
50 - Run: func(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environment) error {
51 - log.Error("The 'ipfs urlstore' command is deprecated, please use 'ipfs add --nocopy --cid-version=1")
52 -
53 - urlString := req.Arguments[0]
54 - if !filestore.IsURL(req.Arguments[0]) {
55 - return fmt.Errorf("unsupported url syntax: %s", urlString)
56 - }
57 -
58 - url, err := url.Parse(urlString)
59 - if err != nil {
60 - return err
61 - }
62 -
63 - enc, err := cmdenv.GetCidEncoder(req)
64 - if err != nil {
65 - return err
66 - }
67 -
68 - api, err := cmdenv.GetApi(env, req)
69 - if err != nil {
70 - return err
71 - }
72 -
73 - useTrickledag, _ := req.Options[trickleOptionName].(bool)
74 - dopin, _ := req.Options[pinOptionName].(bool)
75 -
76 - opts := []options.UnixfsAddOption{
77 - options.Unixfs.Pin(dopin),
78 - options.Unixfs.CidVersion(1),
79 - options.Unixfs.RawLeaves(true),
80 - options.Unixfs.Nocopy(true),
81 - }
82 -
83 - if useTrickledag {
84 - opts = append(opts, options.Unixfs.Layout(options.TrickleLayout))
85 - }
86 -
87 - file := files.NewWebFile(url)
88 -
89 - path, err := api.Unixfs().Add(req.Context, file, opts...)
90 - if err != nil {
91 - return err
92 - }
93 - size, _ := file.Size()
94 - return cmds.EmitOnce(res, &BlockStat{
95 - Key: enc.Encode(path.RootCid()),
96 - Size: int(size),
97 - })
98 - },
99 - Encoders: cmds.EncoderMap{
100 - cmds.Text: cmds.MakeTypedEncoder(func(req *cmds.Request, w io.Writer, bs *BlockStat) error {
101 - _, err := fmt.Fprintln(w, bs.Key)
102 - return err
103 - }),
104 - },
105 -}
docs/changelogs/v0.26.md new
+29
@@ -0,0 +1,29 @@
1 +# Kubo changelog v0.26
2 +
3 +- [v0.26.0](#v0260)
4 +
5 +## v0.26.0
6 +
7 +- [Overview](#overview)
8 +- [🔦 Highlights](#-highlights)
9 + - [Several deprecated commands have been removed](#several-deprecated-commands-have-been-removed)
10 +- [📝 Changelog](#-changelog)
11 +- [👨‍👩‍👧‍👦 Contributors](#-contributors)
12 +
13 +### Overview
14 +
15 +### 🔦 Highlights
16 +
17 +#### Several deprecated commands have been removed
18 +
19 +Several deprecated commands have been removed:
20 +
21 +- `ipfs urlstore` deprecated in [April 2019, Kubo 0.4.21](https://github.com/ipfs/kubo/commit/8beaee63b3fa634c59b85179286ad3873921a535), use `ipfs add -q --nocopy --cid-version=1 {url}` instead.
22 +- `ipfs repo fsck` deprecated in [July 2019, Kubo 0.5.0](https://github.com/ipfs/kubo/commit/288a83ce7dcbf4a2498e06e4a95245bbb5e30f45)
23 +- `ipfs file` (and `ipfs file ls`) deprecated in [November 2020, Kubo 0.8.0](https://github.com/ipfs/kubo/commit/ec64dc5c396e7114590e15909384fabce0035482), use `ipfs ls` and `ipfs files ls` instead.
24 +- `ipfs dns` deprecated in [April 2022, Kubo 0.13](https://github.com/ipfs/kubo/commit/76ae33a9f3f9abd166d1f6f23d6a8a0511510e3c), use `ipfs resolve /ipns/{name}` instead.
25 +- `ipfs tar` deprecated [April 2022, Kubo 0.13](https://github.com/ipfs/kubo/pull/8849)
26 +
27 +### 📝 Changelog
28 +
29 +### 👨‍👩‍👧‍👦 Contributors
tar/format.go deleted
-227
@@ -1,227 +0,0 @@
1 -package tarfmt
2 -
3 -import (
4 - "archive/tar"
5 - "bytes"
6 - "context"
7 - "errors"
8 - "io"
9 - "path"
10 - "strings"
11 -
12 - dag "github.com/ipfs/boxo/ipld/merkledag"
13 - "github.com/ipfs/boxo/ipld/merkledag/dagutils"
14 - importer "github.com/ipfs/boxo/ipld/unixfs/importer"
15 - uio "github.com/ipfs/boxo/ipld/unixfs/io"
16 -
17 - chunker "github.com/ipfs/boxo/chunker"
18 - ipld "github.com/ipfs/go-ipld-format"
19 - logging "github.com/ipfs/go-log"
20 -)
21 -
22 -var log = logging.Logger("tarfmt")
23 -
24 -var (
25 - blockSize = 512
26 - zeroBlock = make([]byte, blockSize)
27 -)
28 -
29 -func marshalHeader(h *tar.Header) ([]byte, error) {
30 - buf := new(bytes.Buffer)
31 - w := tar.NewWriter(buf)
32 - err := w.WriteHeader(h)
33 - if err != nil {
34 - return nil, err
35 - }
36 - return buf.Bytes(), nil
37 -}
38 -
39 -// ImportTar imports a tar file into the given DAGService and returns the root
40 -// node.
41 -func ImportTar(ctx context.Context, r io.Reader, ds ipld.DAGService) (*dag.ProtoNode, error) {
42 - tr := tar.NewReader(r)
43 -
44 - root := new(dag.ProtoNode)
45 - root.SetData([]byte("ipfs/tar"))
46 -
47 - e := dagutils.NewDagEditor(root, ds)
48 -
49 - for {
50 - h, err := tr.Next()
51 - if err != nil {
52 - if err == io.EOF {
53 - break
54 - }
55 - return nil, err
56 - }
57 -
58 - header := new(dag.ProtoNode)
59 -
60 - headerBytes, err := marshalHeader(h)
61 - if err != nil {
62 - return nil, err
63 - }
64 -
65 - header.SetData(headerBytes)
66 -
67 - if h.Size > 0 {
68 - spl := chunker.NewRabin(tr, uint64(chunker.DefaultBlockSize))
69 - nd, err := importer.BuildDagFromReader(ds, spl)
70 - if err != nil {
71 - return nil, err
72 - }
73 -
74 - err = header.AddNodeLink("data", nd)
75 - if err != nil {
76 - return nil, err
77 - }
78 - }
79 -
80 - err = ds.Add(ctx, header)
81 - if err != nil {
82 - return nil, err
83 - }
84 -
85 - path := escapePath(h.Name)
86 - err = e.InsertNodeAtPath(context.Background(), path, header, func() *dag.ProtoNode { return new(dag.ProtoNode) })
87 - if err != nil {
88 - return nil, err
89 - }
90 - }
91 -
92 - return e.Finalize(ctx, ds)
93 -}
94 -
95 -// adds a '-' to the beginning of each path element so we can use 'data' as a
96 -// special link in the structure without having to worry about.
97 -func escapePath(pth string) string {
98 - elems := strings.Split(strings.Trim(pth, "/"), "/")
99 - for i, e := range elems {
100 - elems[i] = "-" + e
101 - }
102 - return path.Join(elems...)
103 -}
104 -
105 -type tarReader struct {
106 - links []*ipld.Link
107 - ds ipld.DAGService
108 -
109 - childRead *tarReader
110 - hdrBuf *bytes.Reader
111 - fileRead *countReader
112 - pad int
113 -
114 - ctx context.Context
115 -}
116 -
117 -func (tr *tarReader) Read(b []byte) (int, error) {
118 - // if we have a header to be read, it takes priority
119 - if tr.hdrBuf != nil {
120 - n, err := tr.hdrBuf.Read(b)
121 - if err == io.EOF {
122 - tr.hdrBuf = nil
123 - return n, nil
124 - }
125 - return n, err
126 - }
127 -
128 - // no header remaining, check for recursive
129 - if tr.childRead != nil {
130 - n, err := tr.childRead.Read(b)
131 - if err == io.EOF {
132 - tr.childRead = nil
133 - return n, nil
134 - }
135 - return n, err
136 - }
137 -
138 - // check for filedata to be read
139 - if tr.fileRead != nil {
140 - n, err := tr.fileRead.Read(b)
141 - if err == io.EOF {
142 - nr := tr.fileRead.n
143 - tr.pad = (blockSize - (nr % blockSize)) % blockSize
144 - tr.fileRead.Close()
145 - tr.fileRead = nil
146 - return n, nil
147 - }
148 - return n, err
149 - }
150 -
151 - // filedata reads must be padded out to 512 byte offsets
152 - if tr.pad > 0 {
153 - n := copy(b, zeroBlock[:tr.pad])
154 - tr.pad -= n
155 - return n, nil
156 - }
157 -
158 - if len(tr.links) == 0 {
159 - return 0, io.EOF
160 - }
161 -
162 - next := tr.links[0]
163 - tr.links = tr.links[1:]
164 -
165 - headerNd, err := next.GetNode(tr.ctx, tr.ds)
166 - if err != nil {
167 - return 0, err
168 - }
169 -
170 - hndpb, ok := headerNd.(*dag.ProtoNode)
171 - if !ok {
172 - return 0, dag.ErrNotProtobuf
173 - }
174 -
175 - tr.hdrBuf = bytes.NewReader(hndpb.Data())
176 -
177 - dataNd, err := hndpb.GetLinkedProtoNode(tr.ctx, tr.ds, "data")
178 - if err != nil && !errors.Is(err, dag.ErrLinkNotFound) {
179 - return 0, err
180 - }
181 -
182 - if err == nil {
183 - dr, err := uio.NewDagReader(tr.ctx, dataNd, tr.ds)
184 - if err != nil {
185 - log.Error("dagreader error: ", err)
186 - return 0, err
187 - }
188 -
189 - tr.fileRead = &countReader{r: dr}
190 - } else if len(headerNd.Links()) > 0 {
191 - tr.childRead = &tarReader{
192 - links: headerNd.Links(),
193 - ds: tr.ds,
194 - ctx: tr.ctx,
195 - }
196 - }
197 -
198 - return tr.Read(b)
199 -}
200 -
201 -// ExportTar exports the passed DAG as a tar file. This function is the inverse
202 -// of ImportTar.
203 -func ExportTar(ctx context.Context, root *dag.ProtoNode, ds ipld.DAGService) (io.Reader, error) {
204 - if string(root.Data()) != "ipfs/tar" {
205 - return nil, errors.New("not an IPFS tarchive")
206 - }
207 - return &tarReader{
208 - links: root.Links(),
209 - ds: ds,
210 - ctx: ctx,
211 - }, nil
212 -}
213 -
214 -type countReader struct {
215 - r io.ReadCloser
216 - n int
217 -}
218 -
219 -func (r *countReader) Read(b []byte) (int, error) {
220 - n, err := r.r.Read(b)
221 - r.n += n
222 - return n, err
223 -}
224 -
225 -func (r *countReader) Close() error {
226 - return r.r.Close()
227 -}
test/cli/basic_commands_test.go
-6
@@ -116,9 +116,6 @@ func TestAllRootCommandsAreMentionedInHelpText(t *testing.T) {
116 notInHelp := map[string]bool{
117 "object": true,
118 "shutdown": true,
119 - "tar": true,
120 - "urlstore": true,
121 - "dns": true,
119 }
120
121 helpMsg := strings.TrimSpace(node.IPFS("--help").Stdout.String())
@@ -159,7 +156,6 @@ func TestCommandDocsWidth(t *testing.T) {
156 "ipfs pin verify": true,
157 "ipfs dht get": true,
158 "ipfs pin remote service add": true,
162 - "ipfs file ls": true,
159 "ipfs pin update": true,
160 "ipfs pin rm": true,
161 "ipfs p2p": true,
@@ -177,10 +173,8 @@ func TestCommandDocsWidth(t *testing.T) {
173 "ipfs swarm addrs local": true,
174 "ipfs files ls": true,
175 "ipfs stats bw": true,
180 - "ipfs urlstore add": true,
176 "ipfs swarm peers": true,
177 "ipfs pubsub sub": true,
183 - "ipfs repo fsck": true,
178 "ipfs files write": true,
179 "ipfs swarm limit": true,
180 "ipfs commands completion fish": true,
test/sharness/t0200-unixfs-ls.sh deleted
-140
@@ -1,140 +0,0 @@
1 -#!/usr/bin/env bash
2 -#
3 -# Copyright (c) 2014 Christian Couder
4 -# MIT Licensed; see the LICENSE file in this repository.
5 -#
6 -
7 -test_description="Test file ls command"
8 -
9 -. lib/test-lib.sh
10 -
11 -test_init_ipfs
12 -
13 -test_ls_cmd() {
14 -
15 - test_expect_success "'ipfs add -r testData' succeeds" '
16 - mkdir -p testData testData/d1 testData/d2 &&
17 - echo "test" >testData/f1 &&
18 - echo "data" >testData/f2 &&
19 - echo "hello" >testData/d1/a &&
20 - random 128 42 >testData/d1/128 &&
21 - echo "world" >testData/d2/a &&
22 - random 1024 42 >testData/d2/1024 &&
23 - ipfs add -r testData >actual_add
24 - '
25 -
26 - test_expect_success "'ipfs add' output looks good" '
27 - cat <<-\EOF >expected_add &&
28 -added QmQNd6ubRXaNG6Prov8o6vk3bn6eWsj9FxLGrAVDUAGkGe testData/d1/128
29 -added QmZULkCELmmk5XNfCgTnCyFgAVxBRBXyDHGGMVoLFLiXEN testData/d1/a
30 -added QmbQBUSRL9raZtNXfpTDeaxQapibJEG6qEY8WqAN22aUzd testData/d2/1024
31 -added QmaRGe7bVmVaLmxbrMiVNXqW4pRNNp3xq7hFtyRKA3mtJL testData/d2/a
32 -added QmeomffUNfmQy76CQGy9NdmqEnnHU9soCexBnGU3ezPHVH testData/f1
33 -added QmNtocSs7MoDkJMc1RkyisCSKvLadujPsfJfSdJ3e1eA1M testData/f2
34 -added QmSix55yz8CzWXf5ZVM9vgEvijnEeeXiTSarVtsqiiCJss testData/d1
35 -added QmR3jhV4XpxxPjPT3Y8vNnWvWNvakdcT3H6vqpRBsX1MLy testData/d2
36 -added QmfNy183bXiRVyrhyWtq3TwHn79yHEkiAGFr18P7YNzESj testData
37 -EOF
38 - test_cmp expected_add actual_add
39 - '
40 -
41 - test_expect_success "'ipfs file ls <dir>' succeeds" '
42 - ipfs file ls QmR3jhV4XpxxPjPT3Y8vNnWvWNvakdcT3H6vqpRBsX1MLy >actual_ls_one_directory
43 - '
44 -
45 - test_expect_success "'ipfs file ls <dir>' output looks good" '
46 - cat <<-\EOF >expected_ls_one_directory &&
47 -1024
48 -a
49 -EOF
50 - test_cmp expected_ls_one_directory actual_ls_one_directory
51 - '
52 -
53 - test_expect_success "'ipfs file ls <three dir hashes>' succeeds" '
54 - ipfs file ls QmfNy183bXiRVyrhyWtq3TwHn79yHEkiAGFr18P7YNzESj QmR3jhV4XpxxPjPT3Y8vNnWvWNvakdcT3H6vqpRBsX1MLy QmSix55yz8CzWXf5ZVM9vgEvijnEeeXiTSarVtsqiiCJss >actual_ls_three_directories
55 - '
56 -
57 - test_expect_success "'ipfs file ls <three dir hashes>' output looks good" '
58 - cat <<-\EOF >expected_ls_three_directories &&
59 -QmR3jhV4XpxxPjPT3Y8vNnWvWNvakdcT3H6vqpRBsX1MLy:
60 -1024
61 -a
62 -
63 -QmSix55yz8CzWXf5ZVM9vgEvijnEeeXiTSarVtsqiiCJss:
64 -128
65 -a
66 -
67 -QmfNy183bXiRVyrhyWtq3TwHn79yHEkiAGFr18P7YNzESj:
68 -d1
69 -d2
70 -f1
71 -f2
72 -EOF
73 - test_cmp expected_ls_three_directories actual_ls_three_directories
74 - '
75 -
76 - test_expect_success "'ipfs file ls <file hashes>' succeeds" '
77 - ipfs file ls /ipfs/QmR3jhV4XpxxPjPT3Y8vNnWvWNvakdcT3H6vqpRBsX1MLy/1024 QmQNd6ubRXaNG6Prov8o6vk3bn6eWsj9FxLGrAVDUAGkGe >actual_ls_file
78 - '
79 -
80 - test_expect_success "'ipfs file ls <file hashes>' output looks good" '
81 - cat <<-\EOF >expected_ls_file &&
82 -/ipfs/QmR3jhV4XpxxPjPT3Y8vNnWvWNvakdcT3H6vqpRBsX1MLy/1024
83 -QmQNd6ubRXaNG6Prov8o6vk3bn6eWsj9FxLGrAVDUAGkGe
84 -EOF
85 - test_cmp expected_ls_file actual_ls_file
86 - '
87 -
88 - test_expect_success "'ipfs file ls <duplicates>' succeeds" '
89 - ipfs file ls /ipfs/QmfNy183bXiRVyrhyWtq3TwHn79yHEkiAGFr18P7YNzESj/d1 /ipfs/QmSix55yz8CzWXf5ZVM9vgEvijnEeeXiTSarVtsqiiCJss /ipfs/QmR3jhV4XpxxPjPT3Y8vNnWvWNvakdcT3H6vqpRBsX1MLy/1024 /ipfs/QmbQBUSRL9raZtNXfpTDeaxQapibJEG6qEY8WqAN22aUzd >actual_ls_duplicates_file
90 - '
91 -
92 - test_expect_success "'ipfs file ls <duplicates>' output looks good" '
93 - cat <<-\EOF >expected_ls_duplicates_file &&
94 -/ipfs/QmR3jhV4XpxxPjPT3Y8vNnWvWNvakdcT3H6vqpRBsX1MLy/1024
95 -/ipfs/QmbQBUSRL9raZtNXfpTDeaxQapibJEG6qEY8WqAN22aUzd
96 -
97 -/ipfs/QmSix55yz8CzWXf5ZVM9vgEvijnEeeXiTSarVtsqiiCJss:
98 -/ipfs/QmfNy183bXiRVyrhyWtq3TwHn79yHEkiAGFr18P7YNzESj/d1:
99 -128
100 -a
101 -EOF
102 - test_cmp expected_ls_duplicates_file actual_ls_duplicates_file
103 - '
104 -
105 - test_expect_success "'ipfs --encoding=json file ls <file hashes>' succeeds" '
106 - ipfs --encoding=json file ls /ipfs/QmR3jhV4XpxxPjPT3Y8vNnWvWNvakdcT3H6vqpRBsX1MLy/1024 >actual_json_ls_file
107 - '
108 -
109 - test_expect_success "'ipfs --encoding=json file ls <file hashes>' output looks good" '
110 - cat <<-\EOF >expected_json_ls_file_trailing_newline &&
111 -{"Arguments":{"/ipfs/QmR3jhV4XpxxPjPT3Y8vNnWvWNvakdcT3H6vqpRBsX1MLy/1024":"QmbQBUSRL9raZtNXfpTDeaxQapibJEG6qEY8WqAN22aUzd"},"Objects":{"QmbQBUSRL9raZtNXfpTDeaxQapibJEG6qEY8WqAN22aUzd":{"Hash":"QmbQBUSRL9raZtNXfpTDeaxQapibJEG6qEY8WqAN22aUzd","Size":1024,"Type":"File","Links":null}}}
112 -EOF
113 - printf "%s\n" "$(cat expected_json_ls_file_trailing_newline)" >expected_json_ls_file &&
114 - test_cmp expected_json_ls_file actual_json_ls_file
115 - '
116 -
117 - test_expect_success "'ipfs --encoding=json file ls <duplicates>' succeeds" '
118 - ipfs --encoding=json file ls /ipfs/QmfNy183bXiRVyrhyWtq3TwHn79yHEkiAGFr18P7YNzESj/d1 /ipfs/QmSix55yz8CzWXf5ZVM9vgEvijnEeeXiTSarVtsqiiCJss /ipfs/QmR3jhV4XpxxPjPT3Y8vNnWvWNvakdcT3H6vqpRBsX1MLy/1024 /ipfs/QmbQBUSRL9raZtNXfpTDeaxQapibJEG6qEY8WqAN22aUzd >actual_json_ls_duplicates_file
119 - '
120 -
121 - test_expect_success "'ipfs --encoding=json file ls <duplicates>' output looks good" '
122 - cat <<-\EOF >expected_json_ls_duplicates_file_trailing_newline &&
123 -{"Arguments":{"/ipfs/QmR3jhV4XpxxPjPT3Y8vNnWvWNvakdcT3H6vqpRBsX1MLy/1024":"QmbQBUSRL9raZtNXfpTDeaxQapibJEG6qEY8WqAN22aUzd","/ipfs/QmSix55yz8CzWXf5ZVM9vgEvijnEeeXiTSarVtsqiiCJss":"QmSix55yz8CzWXf5ZVM9vgEvijnEeeXiTSarVtsqiiCJss","/ipfs/QmbQBUSRL9raZtNXfpTDeaxQapibJEG6qEY8WqAN22aUzd":"QmbQBUSRL9raZtNXfpTDeaxQapibJEG6qEY8WqAN22aUzd","/ipfs/QmfNy183bXiRVyrhyWtq3TwHn79yHEkiAGFr18P7YNzESj/d1":"QmSix55yz8CzWXf5ZVM9vgEvijnEeeXiTSarVtsqiiCJss"},"Objects":{"QmSix55yz8CzWXf5ZVM9vgEvijnEeeXiTSarVtsqiiCJss":{"Hash":"QmSix55yz8CzWXf5ZVM9vgEvijnEeeXiTSarVtsqiiCJss","Size":0,"Type":"Directory","Links":[{"Name":"128","Hash":"QmQNd6ubRXaNG6Prov8o6vk3bn6eWsj9FxLGrAVDUAGkGe","Size":128,"Type":"File"},{"Name":"a","Hash":"QmZULkCELmmk5XNfCgTnCyFgAVxBRBXyDHGGMVoLFLiXEN","Size":6,"Type":"File"}]},"QmbQBUSRL9raZtNXfpTDeaxQapibJEG6qEY8WqAN22aUzd":{"Hash":"QmbQBUSRL9raZtNXfpTDeaxQapibJEG6qEY8WqAN22aUzd","Size":1024,"Type":"File","Links":null}}}
124 -EOF
125 - printf "%s\n" "$(cat expected_json_ls_duplicates_file_trailing_newline)" >expected_json_ls_duplicates_file &&
126 - test_cmp expected_json_ls_duplicates_file actual_json_ls_duplicates_file
127 - '
128 -
129 -}
130 -
131 -
132 -# should work offline
133 -test_ls_cmd
134 -
135 -# should work online
136 -test_launch_ipfs_daemon
137 -test_ls_cmd
138 -test_kill_ipfs_daemon
139 -
140 -test_done
test/sharness/t0210-tar.sh deleted
-58
@@ -1,58 +0,0 @@
1 -#!/usr/bin/env bash
2 -#
3 -# Copyright (c) 2015 Jeromy Johnson
4 -# MIT Licensed; see the LICENSE file in this repository.
5 -#
6 -
7 -test_description="Test tar commands"
8 -
9 -. lib/test-lib.sh
10 -
11 -test_init_ipfs
12 -
13 -test_expect_success "create some random files" '
14 - mkdir foo &&
15 - random 10000 > foo/a &&
16 - random 12345 > foo/b &&
17 - mkdir foo/bar &&
18 - random 5432 > foo/bar/baz &&
19 - ln -s ../a foo/bar/link &&
20 - echo "exit" > foo/script &&
21 - chmod +x foo/script
22 -'
23 -
24 -test_expect_success "tar those random files up" '
25 - tar cf files.tar foo/
26 -'
27 -
28 -test_expect_success "'ipfs tar add' succeeds" '
29 - TAR_HASH=$(ipfs tar add files.tar)
30 -'
31 -
32 -test_expect_success "'ipfs tar cat' succeeds" '
33 - mkdir output &&
34 - ipfs tar cat $TAR_HASH > output/out.tar
35 -'
36 -
37 -test_expect_success "can extract tar" '
38 - tar xf output/out.tar -C output/
39 -'
40 -
41 -test_expect_success "files look right" '
42 - diff foo/a output/foo/a &&
43 - diff foo/b output/foo/b &&
44 - diff foo/bar/baz output/foo/bar/baz &&
45 - [ -L output/foo/bar/link ] &&
46 - [ -x foo/script ]
47 -'
48 -
49 -test_expect_success "'ipfs tar add --cid-base=base32' succeeds" '
50 - ipfs tar add --cid-base=base32 files.tar > actual
51 -'
52 -
53 -test_expect_success "'ipfs tar add --cid-base=base32' has correct hash" '
54 - ipfs cid base32 $TAR_HASH > expected &&
55 - test_cmp expected actual
56 -'
57 -
58 -test_done
test/sharness/t0272-urlstore.sh
-1
@@ -191,7 +191,6 @@ EOF
191 '
192 }
193
194 -test_urlstore urlstore add
194 test_urlstore add -q --nocopy --cid-version=1
195
196 test_done