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"
)
func put(c *cli.Context) {
func add(c *cli.Context) {
config, err := parseInput(c)
if err != nil {
log.Fatal(err)

View File

@ -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)
}

View File

@ -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)
}

View File

@ -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",