aboutsummaryrefslogtreecommitdiffstats
path: root/cmd/swarm/list.go
diff options
context:
space:
mode:
authorLewis Marshall <lewis@lmars.net>2017-04-07 06:22:22 +0800
committerFelix Lange <fjl@users.noreply.github.com>2017-04-07 06:22:22 +0800
commit71fdaa42386173da7bfa13f1728c394aeeb4eb01 (patch)
tree364a169f650982d3b2880c95e40e2c91cb27c86e /cmd/swarm/list.go
parent9aca9e6deb243b87cc75325be593a3b0c2f0a113 (diff)
downloadgo-tangerine-71fdaa42386173da7bfa13f1728c394aeeb4eb01.tar
go-tangerine-71fdaa42386173da7bfa13f1728c394aeeb4eb01.tar.gz
go-tangerine-71fdaa42386173da7bfa13f1728c394aeeb4eb01.tar.bz2
go-tangerine-71fdaa42386173da7bfa13f1728c394aeeb4eb01.tar.lz
go-tangerine-71fdaa42386173da7bfa13f1728c394aeeb4eb01.tar.xz
go-tangerine-71fdaa42386173da7bfa13f1728c394aeeb4eb01.tar.zst
go-tangerine-71fdaa42386173da7bfa13f1728c394aeeb4eb01.zip
swarm/api: refactor and improve HTTP API (#3773)
This PR deprecates the file related RPC calls in favour of an improved HTTP API. The main aim is to expose a simple to use API which can be consumed by thin clients (e.g. curl and HTML forms) without the need for complex logic (e.g. manipulating prefix trie manifests).
Diffstat (limited to 'cmd/swarm/list.go')
-rw-r--r--cmd/swarm/list.go7
1 files changed, 5 insertions, 2 deletions
diff --git a/cmd/swarm/list.go b/cmd/swarm/list.go
index 3a68fef03..06d3883cf 100644
--- a/cmd/swarm/list.go
+++ b/cmd/swarm/list.go
@@ -44,7 +44,7 @@ func list(ctx *cli.Context) {
bzzapi := strings.TrimRight(ctx.GlobalString(SwarmApiFlag.Name), "/")
client := swarm.NewClient(bzzapi)
- entries, err := client.ManifestFileList(manifest, prefix)
+ list, err := client.List(manifest, prefix)
if err != nil {
utils.Fatalf("Failed to generate file and directory list: %s", err)
}
@@ -52,7 +52,10 @@ func list(ctx *cli.Context) {
w := tabwriter.NewWriter(os.Stdout, 1, 2, 2, ' ', 0)
defer w.Flush()
fmt.Fprintln(w, "HASH\tCONTENT TYPE\tPATH")
- for _, entry := range entries {
+ for _, prefix := range list.CommonPrefixes {
+ fmt.Fprintf(w, "%s\t%s\t%s\n", "", "DIR", prefix)
+ }
+ for _, entry := range list.Entries {
fmt.Fprintf(w, "%s\t%s\t%s\n", entry.Hash, entry.ContentType, entry.Path)
}
}