Implement add, commit - instead of put, encoded

This commit is contained in:
Harshavardhana 2014-12-15 21:55:54 -08:00
parent 68eb14a1f6
commit 65e2031cfc
4 changed files with 32 additions and 14 deletions

View File

@ -8,7 +8,7 @@ import (
"github.com/codegangsta/cli" "github.com/codegangsta/cli"
) )
func put(c *cli.Context) { func add(c *cli.Context) {
config, err := parseInput(c) config, err := parseInput(c)
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)

View File

@ -1,12 +1,29 @@
package main package main
import ( import (
"io/ioutil"
"log" "log"
"os"
"path"
"github.com/codegangsta/cli" "github.com/codegangsta/cli"
) )
func encode(c *cli.Context) { func cleanupStagingDir(stagingDir string) {
filelist, err := ioutil.ReadDir(stagingDir)
if err != nil {
log.Fatal(err)
}
for _, file := range filelist {
_file := path.Join(stagingDir, file.Name())
if err := os.Remove(_file); err != nil {
log.Fatal(err)
}
}
}
func commit(c *cli.Context) {
config, err := parseInput(c) config, err := parseInput(c)
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
@ -34,4 +51,7 @@ func encode(c *cli.Context) {
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }
// Cleanup stagingDir
cleanupStagingDir(config.stagingDir)
} }

View File

@ -22,7 +22,10 @@ func get(c *cli.Context) {
log.Fatal("Please specify a valid object name \n # erasure-demo get [OBJECTNAME]") log.Fatal("Please specify a valid object name \n # erasure-demo get [OBJECTNAME]")
} }
if objectReader, err = erasureGet(config, objectName); err != nil { getConfig := config
getConfig.k = 10
getConfig.m = 6
if objectReader, err = erasureGet(getConfig, objectName); err != nil {
log.Fatal(err) log.Fatal(err)
} }

View File

@ -12,9 +12,9 @@ func main() {
app.Usage = "minio - object storage" app.Usage = "minio - object storage"
app.Commands = []cli.Command{ app.Commands = []cli.Command{
{ {
Name: "encode", Name: "commit",
Usage: "erasure encode a byte stream", Usage: "provide higher protection for uploaded object",
Action: encode, Action: commit,
Flags: []cli.Flag{ Flags: []cli.Flag{
cli.StringFlag{ cli.StringFlag{
Name: "root", Name: "root",
@ -48,11 +48,6 @@ func main() {
Value: getObjectdir(".minio/erasure"), Value: getObjectdir(".minio/erasure"),
Usage: "", Usage: "",
}, },
cli.StringFlag{
Name: "protection-level",
Value: "10,6",
Usage: "data,parity",
},
cli.StringFlag{ cli.StringFlag{
Name: "block-size", Name: "block-size",
Value: "1M", Value: "1M",
@ -61,9 +56,9 @@ func main() {
}, },
}, },
{ {
Name: "put", Name: "add",
Usage: "put an object", Usage: "add an object",
Action: put, Action: add,
Flags: []cli.Flag{ Flags: []cli.Flag{
cli.StringFlag{ cli.StringFlag{
Name: "staging", Name: "staging",