From 65e2031cfc804f6a2bb5e51168c3075e956aac45 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Mon, 15 Dec 2014 21:55:54 -0800 Subject: [PATCH] Implement add, commit - instead of put, encoded --- cmd/minio/{put.go => add.go} | 2 +- cmd/minio/{encode.go => commit.go} | 22 +++++++++++++++++++++- cmd/minio/get.go | 5 ++++- cmd/minio/minio.go | 17 ++++++----------- 4 files changed, 32 insertions(+), 14 deletions(-) rename cmd/minio/{put.go => add.go} (96%) rename cmd/minio/{encode.go => commit.go} (63%) diff --git a/cmd/minio/put.go b/cmd/minio/add.go similarity index 96% rename from cmd/minio/put.go rename to cmd/minio/add.go index 2336b3bbc..9322ce343 100644 --- a/cmd/minio/put.go +++ b/cmd/minio/add.go @@ -8,7 +8,7 @@ import ( "github.com/codegangsta/cli" ) -func put(c *cli.Context) { +func add(c *cli.Context) { config, err := parseInput(c) if err != nil { log.Fatal(err) diff --git a/cmd/minio/encode.go b/cmd/minio/commit.go similarity index 63% rename from cmd/minio/encode.go rename to cmd/minio/commit.go index 9ba59fe40..6e25eaf09 100644 --- a/cmd/minio/encode.go +++ b/cmd/minio/commit.go @@ -1,12 +1,29 @@ package main import ( + "io/ioutil" "log" + "os" + "path" "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) if err != nil { log.Fatal(err) @@ -34,4 +51,7 @@ func encode(c *cli.Context) { if err != nil { log.Fatal(err) } + + // Cleanup stagingDir + cleanupStagingDir(config.stagingDir) } diff --git a/cmd/minio/get.go b/cmd/minio/get.go index 1d1573477..c3cc0af96 100644 --- a/cmd/minio/get.go +++ b/cmd/minio/get.go @@ -22,7 +22,10 @@ func get(c *cli.Context) { 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) } diff --git a/cmd/minio/minio.go b/cmd/minio/minio.go index 798b88b8b..69d34f69a 100644 --- a/cmd/minio/minio.go +++ b/cmd/minio/minio.go @@ -12,9 +12,9 @@ func main() { app.Usage = "minio - object storage" app.Commands = []cli.Command{ { - Name: "encode", - Usage: "erasure encode a byte stream", - Action: encode, + Name: "commit", + Usage: "provide higher protection for uploaded object", + Action: commit, Flags: []cli.Flag{ cli.StringFlag{ Name: "root", @@ -48,11 +48,6 @@ func main() { Value: getObjectdir(".minio/erasure"), Usage: "", }, - cli.StringFlag{ - Name: "protection-level", - Value: "10,6", - Usage: "data,parity", - }, cli.StringFlag{ Name: "block-size", Value: "1M", @@ -61,9 +56,9 @@ func main() { }, }, { - Name: "put", - Usage: "put an object", - Action: put, + Name: "add", + Usage: "add an object", + Action: add, Flags: []cli.Flag{ cli.StringFlag{ Name: "staging",