5748: Clean up comments and variable names.
authorTom Clegg <tom@curoverse.com>
Wed, 6 May 2015 21:10:35 +0000 (17:10 -0400)
committerTom Clegg <tom@curoverse.com>
Wed, 6 May 2015 21:11:01 +0000 (17:11 -0400)
services/keepstore/volume_test.go
services/keepstore/volume_unix.go

index b0cbabf800de5ebd040f805949c9d755997c7161..66e0810c972a86c59603f3ab40498e264081072a 100644 (file)
@@ -109,7 +109,7 @@ func (v *MockVolume) Mtime(loc string) (time.Time, error) {
 }
 
 func (v *MockVolume) IndexTo(prefix string, w io.Writer) error {
-       v.gotCall("Index")
+       v.gotCall("IndexTo")
        for loc, block := range v.Store {
                if !IsValidLocator(loc) || !strings.HasPrefix(loc, prefix) {
                        continue
index 7df0b11245d643e4d62e2eaa90239df88769201f..8d23d116185858975a4dcf267eb5d274a8365206 100644 (file)
@@ -218,7 +218,7 @@ func (v *UnixVolume) Status() *VolumeStatus {
 
 // IndexTo writes (to the given Writer) a list of blocks found on this
 // volume which begin with the specified prefix. If the prefix is an
-// empty string, Index writes a complete list of blocks.
+// empty string, IndexTo writes a complete list of blocks.
 //
 // Each block is given in the format
 //
@@ -238,24 +238,22 @@ func (v *UnixVolume) IndexTo(prefix string, w io.Writer) error {
                                        v, path, err)
                                return nil
                        }
-                       locator := filepath.Base(path)
-                       // Skip directories that do not match prefix.
-                       // We know there is nothing interesting inside.
+                       basename := filepath.Base(path)
                        if info.IsDir() &&
-                               !strings.HasPrefix(locator, prefix) &&
-                               !strings.HasPrefix(prefix, locator) {
+                               !strings.HasPrefix(basename, prefix) &&
+                               !strings.HasPrefix(prefix, basename) {
+                               // Skip directories that do not match
+                               // prefix. We know there is nothing
+                               // interesting inside.
                                return filepath.SkipDir
                        }
-                       // Skip any file that is not apparently a locator, e.g. .meta files
-                       if info.IsDir() || !IsValidLocator(locator) {
-                               return nil
-                       }
-                       // Print filenames beginning with prefix
-                       if !strings.HasPrefix(locator, prefix) {
+                       if info.IsDir() ||
+                               !IsValidLocator(basename) ||
+                               !strings.HasPrefix(basename, prefix) {
                                return nil
                        }
                        _, err = fmt.Fprintf(w, "%s+%d %d\n",
-                               locator, info.Size(), info.ModTime().Unix())
+                               basename, info.Size(), info.ModTime().Unix())
                        return err
                })
 }