diff --git a/cmd/swarm/main.go b/cmd/swarm/main.go index 04930760ee..392b049d57 100644 --- a/cmd/swarm/main.go +++ b/cmd/swarm/main.go @@ -152,6 +152,43 @@ The output of this command is supposed to be machine-readable. Prints the swarm hash of file or directory. `, }, + cli.Command{ + Name: "manifest", + Usage: "update a MANIFEST", + ArgsUsage: "manifest COMMAND", + Description: ` +Updates a MANIFEST by adding/removing/updating the hash of a path. +`, + Subcommands: []cli.Command{ + { + Action: add, + Name: "add", + Usage: "add a new path to the manifest", + ArgsUsage: " []", + Description: ` +Adds a new path to the manifest +`, + }, + { + Action: update, + Name: "update", + Usage: "update the hash for an already existing path in the manifest", + ArgsUsage: " []", + Description: ` +Update the hash for an already existing path in the manifest +`, + }, + { + Action: remove, + Name: "remove", + Usage: "removes a path from the manifest", + ArgsUsage: " ", + Description: ` +Removes a path from the manifest +`, + }, + }, + }, } app.Flags = []cli.Flag{ diff --git a/cmd/swarm/upload.go b/cmd/swarm/upload.go index d048bbc401..3b0c4f96e7 100644 --- a/cmd/swarm/upload.go +++ b/cmd/swarm/upload.go @@ -199,3 +199,31 @@ func (c *client) postRaw(mimetype string, size int64, body io.ReadCloser) (strin content, err := ioutil.ReadAll(resp.Body) return string(content), err } + +func (c *client) downloadManifest(mhash string) (manifest, error) { + + mroot := manifest{} + req, err := http.NewRequest("GET", c.api + "/bzzr:/" + mhash, nil) + if err != nil { + return mroot, err + } + resp, err := http.DefaultClient.Do(req) + if err != nil { + return mroot, err + } + defer resp.Body.Close() + + if resp.StatusCode >= 400 { + return mroot, fmt.Errorf("bad status: %s", resp.Status) + + } + content, err := ioutil.ReadAll(resp.Body) + + err = json.Unmarshal(content, &mroot) + if err != nil { + return mroot, fmt.Errorf("Manifest %v is malformed: %v", mhash, err) + } + return mroot, err +} + +