From dddc555491ee1225585cc051c87126c6966af7e3 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Thu, 11 Dec 2014 15:35:25 -0800 Subject: [PATCH] Use objectName with basename for the filepath --- cmd/erasure-demo/get.go | 10 ++++++++-- cmd/erasure-demo/put.go | 12 +++++++----- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/cmd/erasure-demo/get.go b/cmd/erasure-demo/get.go index 9718ea3b7..df818335f 100644 --- a/cmd/erasure-demo/get.go +++ b/cmd/erasure-demo/get.go @@ -31,8 +31,14 @@ func get(c *cli.Context) { } case "erasure": { - if objectReader, err = erasureGet(config, objectName); err != nil { - log.Fatal(err) + if len(objectName) == 0 { + if objectReader, err = erasureGetList(config); err != nil { + log.Fatal(err) + } + } else { + if objectReader, err = erasureGet(config, objectName); err != nil { + log.Fatal(err) + } } } default: diff --git a/cmd/erasure-demo/put.go b/cmd/erasure-demo/put.go index 01d69145e..c025e1731 100644 --- a/cmd/erasure-demo/put.go +++ b/cmd/erasure-demo/put.go @@ -3,6 +3,7 @@ package main import ( "log" "os" + "path" "github.com/codegangsta/cli" ) @@ -12,12 +13,13 @@ func put(c *cli.Context) { if err != nil { log.Fatal(err) } - objectPath := c.Args().Get(0) - var filePath string + var filePath, objectName string switch len(c.Args()) { case 1: - filePath = objectPath + objectName = path.Base(c.Args().Get(0)) + filePath = c.Args().Get(0) case 2: + objectName = c.Args().Get(0) filePath = c.Args().Get(1) default: log.Fatal("Please specify a valid object name \n # erasure-demo put [OBJECTNAME] [FILENAME]") @@ -29,13 +31,13 @@ func put(c *cli.Context) { switch config.storageDriver { case "fs": { - if err := fsPut(config, c.Args().Get(0), inputFile); err != nil { + if err := fsPut(config, objectName, inputFile); err != nil { log.Fatal(err) } } case "erasure": { - if err := erasurePut(config, c.Args().Get(0), inputFile); err != nil { + if err := erasurePut(config, objectName, inputFile); err != nil { log.Fatal(err) } }