[ARVADOS] updated: 30f834eef8916c0d613c098a4897ac932a2e0b37

git at public.curoverse.com git at public.curoverse.com
Tue Apr 29 15:23:08 EDT 2014


Summary of changes:
 services/keep/src/keep/volume_unix.go      |   14 ++++++--------
 services/keep/src/keep/volume_unix_test.go |    2 +-
 2 files changed, 7 insertions(+), 9 deletions(-)

       via  30f834eef8916c0d613c098a4897ac932a2e0b37 (commit)
      from  4ab25f3b39de88d6d2382bb91af9d67bd6de3bd3 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit 30f834eef8916c0d613c098a4897ac932a2e0b37
Author: Tim Pierce <twp at curoverse.com>
Date:   Tue Apr 29 15:24:03 2014 -0400

    Incorporating code review comments (refs #2620)
    
    * use filepath.Join to build file paths instead of fmt.Sprintf
    * use ioutil.ReadAll to ensure that we read the whole file

diff --git a/services/keep/src/keep/volume_unix.go b/services/keep/src/keep/volume_unix.go
index 95e0f4b..88410de 100644
--- a/services/keep/src/keep/volume_unix.go
+++ b/services/keep/src/keep/volume_unix.go
@@ -111,24 +111,22 @@ func (v *UnixVolume) Put(loc string, block []byte) error {
 func (v *UnixVolume) Read(loc string) ([]byte, error) {
 	var f *os.File
 	var err error
-	var nread int
+	var buf []byte
 
-	blockFilename := fmt.Sprintf("%s/%s/%s", v.root, loc[0:3], loc)
+	blockFilename := filepath.Join(v.root, loc[0:3], loc)
 
 	f, err = os.Open(blockFilename)
 	if err != nil {
 		return nil, err
 	}
 
-	var buf = make([]byte, BLOCKSIZE)
-	nread, err = f.Read(buf)
-	if err != nil {
+	if buf, err = ioutil.ReadAll(f); err != nil {
 		log.Printf("%s: reading %s: %s\n", v, blockFilename, err)
 		return buf, err
 	}
 
 	// Success!
-	return buf[:nread], nil
+	return buf, nil
 }
 
 // Write stores a block of data identified by the locator string
@@ -140,7 +138,7 @@ func (v *UnixVolume) Write(loc string, block []byte) error {
 	if v.IsFull() {
 		return FullError
 	}
-	blockDir := fmt.Sprintf("%s/%s", v.root, loc[0:3])
+	blockDir := filepath.Join(v.root, loc[0:3])
 	if err := os.MkdirAll(blockDir, 0755); err != nil {
 		log.Printf("%s: could not create directory %s: %s",
 			loc, blockDir, err)
@@ -152,7 +150,7 @@ func (v *UnixVolume) Write(loc string, block []byte) error {
 		log.Printf("ioutil.TempFile(%s, tmp%s): %s", blockDir, loc, tmperr)
 		return tmperr
 	}
-	blockFilename := fmt.Sprintf("%s/%s", blockDir, loc)
+	blockFilename := filepath.Join(blockDir, loc)
 
 	if _, err := tmpfile.Write(block); err != nil {
 		log.Printf("%s: writing to %s: %s\n", v, blockFilename, err)
diff --git a/services/keep/src/keep/volume_unix_test.go b/services/keep/src/keep/volume_unix_test.go
index d1f1874..278e656 100644
--- a/services/keep/src/keep/volume_unix_test.go
+++ b/services/keep/src/keep/volume_unix_test.go
@@ -158,7 +158,7 @@ func TestGetSerialized(t *testing.T) {
 	}(sem)
 
 	// Wait for all goroutines to finish
-	for done := 0; done < 2; {
+	for done := 0; done < 3; {
 		done += <-sem
 	}
 }

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list